1 /**************************************************************
2 *
3 * Licensed to the Apache Software Foundation (ASF) under one
4 * or more contributor license agreements. See the NOTICE file
5 * distributed with this work for additional information
6 * regarding copyright ownership. The ASF licenses this file
7 * to you under the Apache License, Version 2.0 (the
8 * "License"); you may not use this file except in compliance
9 * with the License. You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing,
14 * software distributed under the License is distributed on an
15 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 * KIND, either express or implied. See the License for the
17 * specific language governing permissions and limitations
18 * under the License.
19 *
20 *************************************************************/
21
22 // MARKER(update_precomp.py): autogen include statement, do not remove
23 #include "precompiled_xmloff.hxx"
24
25 #include <tools/debug.hxx>
26 #include <com/sun/star/lang/XMultiServiceFactory.hpp>
27 #include <com/sun/star/text/TextContentAnchorType.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/text/XTextFrame.hpp>
30 #include <com/sun/star/container/XNamed.hpp>
31 #include <com/sun/star/text/SizeType.hpp>
32 #include <com/sun/star/drawing/XShape.hpp>
33 #include <com/sun/star/document/XEventsSupplier.hpp>
34 #include <com/sun/star/document/XEmbeddedObjectSupplier.hpp>
35 #include <com/sun/star/io/XOutputStream.hpp>
36 #include <com/sun/star/text/HoriOrientation.hpp>
37 #include <com/sun/star/text/VertOrientation.hpp>
38 #include <xmloff/xmlimp.hxx>
39 #include <xmloff/xmltoken.hxx>
40 #include "xmloff/xmlnmspe.hxx"
41 #include <xmloff/nmspmap.hxx>
42 #include <xmloff/xmluconv.hxx>
43 #include "XMLAnchorTypePropHdl.hxx"
44 #include "XMLEmbeddedObjectImportContext.hxx"
45 #include <xmloff/XMLBase64ImportContext.hxx>
46 #include "XMLReplacementImageContext.hxx"
47 #include <xmloff/prstylei.hxx>
48 #include "xmloff/i18nmap.hxx"
49 #include "xexptran.hxx"
50 #include <xmloff/shapeimport.hxx>
51 #include <xmloff/XMLEventsImportContext.hxx>
52 #include "XMLImageMapContext.hxx"
53 #include "XMLTextFrameContext.hxx"
54 #include "XMLTextListBlockContext.hxx"
55 #include "XMLTextListItemContext.hxx"
56 #include <xmloff/attrlist.hxx>
57 #include <comphelper/stl_types.hxx>
58 #include <basegfx/polygon/b2dpolygon.hxx>
59 #include <basegfx/polygon/b2dpolygontools.hxx>
60 #include <basegfx/matrix/b2dhommatrixtools.hxx>
61 #include <basegfx/polygon/b2dpolypolygontools.hxx>
62 #include <map>
63
64 using ::rtl::OUString;
65 using ::rtl::OUStringBuffer;
66
67 using namespace ::com::sun::star;
68 using namespace ::com::sun::star::uno;
69 using namespace ::com::sun::star::text;
70 using namespace ::com::sun::star::xml::sax;
71 using namespace ::com::sun::star::beans;
72 using namespace ::com::sun::star::lang;
73 using namespace ::com::sun::star::container;
74 using namespace ::com::sun::star::drawing;
75 using namespace ::com::sun::star::document;
76 using namespace ::xmloff::token;
77 using ::com::sun::star::document::XEventsSupplier;
78
79 #define XML_TEXT_FRAME_TEXTBOX 1
80 #define XML_TEXT_FRAME_GRAPHIC 2
81 #define XML_TEXT_FRAME_OBJECT 3
82 #define XML_TEXT_FRAME_OBJECT_OLE 4
83 #define XML_TEXT_FRAME_APPLET 5
84 #define XML_TEXT_FRAME_PLUGIN 6
85 #define XML_TEXT_FRAME_FLOATING_FRAME 7
86
87 typedef ::std::map < const ::rtl::OUString, ::rtl::OUString, ::comphelper::UStringLess> ParamMap;
88
89 class XMLTextFrameContextHyperlink_Impl
90 {
91 OUString sHRef;
92 OUString sName;
93 OUString sTargetFrameName;
94 sal_Bool bMap;
95
96 public:
97
98 inline XMLTextFrameContextHyperlink_Impl( const OUString& rHRef,
99 const OUString& rName,
100 const OUString& rTargetFrameName,
101 sal_Bool bMap );
102
GetHRef() const103 const OUString& GetHRef() const { return sHRef; }
GetName() const104 const OUString& GetName() const { return sName; }
GetTargetFrameName() const105 const OUString& GetTargetFrameName() const { return sTargetFrameName; }
GetMap() const106 sal_Bool GetMap() const { return bMap; }
107 };
108
XMLTextFrameContextHyperlink_Impl(const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,sal_Bool bM)109 inline XMLTextFrameContextHyperlink_Impl::XMLTextFrameContextHyperlink_Impl(
110 const OUString& rHRef, const OUString& rName,
111 const OUString& rTargetFrameName, sal_Bool bM ) :
112 sHRef( rHRef ),
113 sName( rName ),
114 sTargetFrameName( rTargetFrameName ),
115 bMap( bM )
116 {
117 }
118
119 // --> OD 2009-07-22 #i73249#
120 class XMLTextFrameTitleOrDescContext_Impl : public SvXMLImportContext
121 {
122 OUString& mrTitleOrDesc;
123
124 public:
125
126 TYPEINFO();
127
128 XMLTextFrameTitleOrDescContext_Impl( SvXMLImport& rImport,
129 sal_uInt16 nPrfx,
130 const ::rtl::OUString& rLName,
131 OUString& rTitleOrDesc );
132 virtual ~XMLTextFrameTitleOrDescContext_Impl();
133
134 virtual void Characters( const OUString& rText );
135 };
136
137 TYPEINIT1( XMLTextFrameTitleOrDescContext_Impl, SvXMLImportContext );
138
XMLTextFrameTitleOrDescContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,OUString & rTitleOrDesc)139 XMLTextFrameTitleOrDescContext_Impl::XMLTextFrameTitleOrDescContext_Impl(
140 SvXMLImport& rImport,
141 sal_uInt16 nPrfx,
142 const OUString& rLName,
143 OUString& rTitleOrDesc )
144 : SvXMLImportContext( rImport, nPrfx, rLName )
145 , mrTitleOrDesc( rTitleOrDesc )
146 {
147 }
148
~XMLTextFrameTitleOrDescContext_Impl()149 XMLTextFrameTitleOrDescContext_Impl::~XMLTextFrameTitleOrDescContext_Impl()
150 {
151 }
152
Characters(const OUString & rText)153 void XMLTextFrameTitleOrDescContext_Impl::Characters( const OUString& rText )
154 {
155 mrTitleOrDesc += rText;
156 }
157 // <--
158
159 // ------------------------------------------------------------------------
160
161 class XMLTextFrameParam_Impl : public SvXMLImportContext
162 {
163 public:
164
165 TYPEINFO();
166
167 XMLTextFrameParam_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
168 const ::rtl::OUString& rLName,
169 const ::com::sun::star::uno::Reference<
170 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
171 sal_uInt16 nType,
172 ParamMap &rParamMap);
173 virtual ~XMLTextFrameParam_Impl();
174 };
175
176 TYPEINIT1( XMLTextFrameParam_Impl, SvXMLImportContext );
177
~XMLTextFrameParam_Impl()178 XMLTextFrameParam_Impl::~XMLTextFrameParam_Impl()
179 {
180 }
181
XMLTextFrameParam_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const::rtl::OUString & rLName,const::com::sun::star::uno::Reference<::com::sun::star::xml::sax::XAttributeList> & xAttrList,sal_uInt16,ParamMap & rParamMap)182 XMLTextFrameParam_Impl::XMLTextFrameParam_Impl(
183 SvXMLImport& rImport, sal_uInt16 nPrfx,
184 const ::rtl::OUString& rLName,
185 const ::com::sun::star::uno::Reference<
186 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
187 sal_uInt16 /*nType*/,
188 ParamMap &rParamMap):
189 SvXMLImportContext( rImport, nPrfx, rLName )
190 {
191 OUString sName, sValue;
192 sal_Bool bFoundValue = sal_False; // to allow empty values
193 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
194 for( sal_Int16 i=0; i < nAttrCount; i++ )
195 {
196 const OUString& rAttrName = xAttrList->getNameByIndex( i );
197 const OUString& rValue = xAttrList->getValueByIndex( i );
198
199 OUString aLocalName;
200 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
201 if ( XML_NAMESPACE_DRAW == nPrefix )
202 {
203 if( IsXMLToken(aLocalName, XML_VALUE) )
204 {
205 sValue = rValue;
206 bFoundValue=sal_True;
207 }
208 else if( IsXMLToken(aLocalName, XML_NAME) )
209 {
210 sName = rValue;
211 }
212 }
213 }
214 if (sName.getLength() && bFoundValue )
215 rParamMap[sName] = sValue;
216 }
217 class XMLTextFrameContourContext_Impl : public SvXMLImportContext
218 {
219 Reference < XPropertySet > xPropSet;
220
221 public:
222
223 TYPEINFO();
224
225 XMLTextFrameContourContext_Impl( SvXMLImport& rImport, sal_uInt16 nPrfx,
226 const ::rtl::OUString& rLName,
227 const ::com::sun::star::uno::Reference<
228 ::com::sun::star::xml::sax::XAttributeList > & xAttrList,
229 const Reference < XPropertySet >& rPropSet,
230 sal_Bool bPath );
231 virtual ~XMLTextFrameContourContext_Impl();
232 };
233
234 TYPEINIT1( XMLTextFrameContourContext_Impl, SvXMLImportContext );
235
XMLTextFrameContourContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,const Reference<XPropertySet> & rPropSet,sal_Bool bPath)236 XMLTextFrameContourContext_Impl::XMLTextFrameContourContext_Impl(
237 SvXMLImport& rImport,
238 sal_uInt16 nPrfx, const OUString& rLName,
239 const Reference< XAttributeList > & xAttrList,
240 const Reference < XPropertySet >& rPropSet,
241 sal_Bool bPath ) :
242 SvXMLImportContext( rImport, nPrfx, rLName ),
243 xPropSet( rPropSet )
244 {
245 OUString sD, sPoints, sViewBox;
246 sal_Bool bPixelWidth = sal_False, bPixelHeight = sal_False;
247 sal_Bool bAuto = sal_False;
248 sal_Int32 nWidth = 0;
249 sal_Int32 nHeight = 0;
250
251 const SvXMLTokenMap& rTokenMap =
252 GetImport().GetTextImport()->GetTextContourAttrTokenMap();
253
254 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
255 for( sal_Int16 i=0; i < nAttrCount; i++ )
256 {
257 const OUString& rAttrName = xAttrList->getNameByIndex( i );
258 const OUString& rValue = xAttrList->getValueByIndex( i );
259
260 OUString aLocalName;
261 sal_uInt16 nPrefix =
262 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
263 &aLocalName );
264 switch( rTokenMap.Get( nPrefix, aLocalName ) )
265 {
266 case XML_TOK_TEXT_CONTOUR_VIEWBOX:
267 sViewBox = rValue;
268 break;
269 case XML_TOK_TEXT_CONTOUR_D:
270 if( bPath )
271 sD = rValue;
272 break;
273 case XML_TOK_TEXT_CONTOUR_POINTS:
274 if( !bPath )
275 sPoints = rValue;
276 break;
277 case XML_TOK_TEXT_CONTOUR_WIDTH:
278 if( GetImport().GetMM100UnitConverter().convertMeasurePx( nWidth,
279 rValue) )
280 bPixelWidth = sal_True;
281 else
282 GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
283 rValue);
284 break;
285 case XML_TOK_TEXT_CONTOUR_HEIGHT:
286 if( GetImport().GetMM100UnitConverter().convertMeasurePx( nHeight,
287 rValue) )
288 bPixelHeight = sal_True;
289 else
290 GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
291 rValue);
292 break;
293 case XML_TOK_TEXT_CONTOUR_AUTO:
294 bAuto = IsXMLToken(rValue, XML_TRUE);
295 break;
296 }
297 }
298
299 OUString sContourPolyPolygon(RTL_CONSTASCII_USTRINGPARAM("ContourPolyPolygon"));
300 Reference < XPropertySetInfo > xPropSetInfo = rPropSet->getPropertySetInfo();
301
302 if(xPropSetInfo->hasPropertyByName(sContourPolyPolygon) && nWidth > 0 && nHeight > 0 && bPixelWidth == bPixelHeight && (bPath ? sD : sPoints).getLength())
303 {
304 const SdXMLImExViewBox aViewBox( sViewBox, GetImport().GetMM100UnitConverter());
305 basegfx::B2DPolyPolygon aPolyPolygon;
306 Any aAny;
307
308 if( bPath )
309 {
310 basegfx::tools::importFromSvgD(aPolyPolygon, sD, true, 0);
311 }
312 else
313 {
314 basegfx::B2DPolygon aPolygon;
315
316 if(basegfx::tools::importFromSvgPoints(aPolygon, sPoints))
317 {
318 aPolyPolygon = basegfx::B2DPolyPolygon(aPolygon);
319 }
320 }
321
322 if(aPolyPolygon.count())
323 {
324 const basegfx::B2DRange aSourceRange(
325 aViewBox.GetX(), aViewBox.GetY(),
326 aViewBox.GetX() + aViewBox.GetWidth(), aViewBox.GetY() + aViewBox.GetHeight());
327 const basegfx::B2DRange aTargetRange(
328 0.0, 0.0,
329 nWidth, nHeight);
330
331 if(!aSourceRange.equal(aTargetRange))
332 {
333 aPolyPolygon.transform(
334 basegfx::tools::createSourceRangeTargetRangeTransform(
335 aSourceRange,
336 aTargetRange));
337 }
338
339 com::sun::star::drawing::PointSequenceSequence aPointSequenceSequence;
340 basegfx::tools::B2DPolyPolygonToUnoPointSequenceSequence(aPolyPolygon, aPointSequenceSequence);
341 aAny <<= aPointSequenceSequence;
342 xPropSet->setPropertyValue( sContourPolyPolygon, aAny );
343 }
344
345 const OUString sIsPixelContour(RTL_CONSTASCII_USTRINGPARAM("IsPixelContour"));
346
347 if( xPropSetInfo->hasPropertyByName( sIsPixelContour ) )
348 {
349 aAny.setValue( &bPixelWidth, ::getBooleanCppuType() );
350 xPropSet->setPropertyValue( sIsPixelContour, aAny );
351 }
352
353 const OUString sIsAutomaticContour(RTL_CONSTASCII_USTRINGPARAM("IsAutomaticContour") );
354
355 if( xPropSetInfo->hasPropertyByName( sIsAutomaticContour ) )
356 {
357 aAny.setValue( &bAuto, ::getBooleanCppuType() );
358 xPropSet->setPropertyValue( sIsAutomaticContour, aAny );
359 }
360 }
361 }
362
~XMLTextFrameContourContext_Impl()363 XMLTextFrameContourContext_Impl::~XMLTextFrameContourContext_Impl()
364 {
365 }
366
367 // ------------------------------------------------------------------------
368
369 class XMLTextFrameContext_Impl : public SvXMLImportContext
370 {
371 ::com::sun::star::uno::Reference <
372 ::com::sun::star::text::XTextCursor > xOldTextCursor;
373 ::com::sun::star::uno::Reference <
374 ::com::sun::star::beans::XPropertySet > xPropSet;
375 ::com::sun::star::uno::Reference <
376 ::com::sun::star::io::XOutputStream > xBase64Stream;
377
378 /// old list item and block (#89891#)
379 bool mbListContextPushed;
380
381 const ::rtl::OUString sWidth;
382 const ::rtl::OUString sWidthType;
383 const ::rtl::OUString sRelativeWidth;
384 const ::rtl::OUString sHeight;
385 const ::rtl::OUString sRelativeHeight;
386 const ::rtl::OUString sSizeType;
387 const ::rtl::OUString sIsSyncWidthToHeight;
388 const ::rtl::OUString sIsSyncHeightToWidth;
389 const ::rtl::OUString sHoriOrient;
390 const ::rtl::OUString sHoriOrientPosition;
391 const ::rtl::OUString sVertOrient;
392 const ::rtl::OUString sVertOrientPosition;
393 const ::rtl::OUString sChainNextName;
394 const ::rtl::OUString sAnchorType;
395 const ::rtl::OUString sAnchorPageNo;
396 const ::rtl::OUString sGraphicURL;
397 const ::rtl::OUString sGraphicFilter;
398 // --> OD 2009-07-22 #i73249#
399 // const ::rtl::OUString sAlternativeText;
400 const ::rtl::OUString sTitle;
401 const ::rtl::OUString sDescription;
402 // <--
403 const ::rtl::OUString sFrameStyleName;
404 const ::rtl::OUString sGraphicRotation;
405 const ::rtl::OUString sTextBoxServiceName;
406 const ::rtl::OUString sGraphicServiceName;
407
408 ::rtl::OUString sName;
409 ::rtl::OUString sStyleName;
410 ::rtl::OUString sNextName;
411 ::rtl::OUString sHRef;
412 ::rtl::OUString sFilterName;
413 ::rtl::OUString sCode;
414 ::rtl::OUString sObject;
415 ::rtl::OUString sArchive;
416 ::rtl::OUString sMimeType;
417 ::rtl::OUString sFrameName;
418 ::rtl::OUString sAppletName;
419 ::rtl::OUString sFilterService;
420 ::rtl::OUString sBase64CharsLeft;
421 ::rtl::OUString sTblName;
422
423 ParamMap aParamMap;
424
425 sal_Int32 nX;
426 sal_Int32 nY;
427 sal_Int32 nWidth;
428 sal_Int32 nHeight;
429 sal_Int32 nZIndex;
430 sal_Int16 nPage;
431 sal_Int16 nRotation;
432 sal_Int16 nRelWidth;
433 sal_Int16 nRelHeight;
434
435 sal_uInt16 nType;
436 ::com::sun::star::text::TextContentAnchorType eAnchorType;
437
438 sal_Bool bMayScript : 1;
439 sal_Bool bMinWidth : 1;
440 sal_Bool bMinHeight : 1;
441 sal_Bool bSyncWidth : 1;
442 sal_Bool bSyncHeight : 1;
443 sal_Bool bCreateFailed : 1;
444 sal_Bool bOwnBase64Stream : 1;
445 bool mbSetNameForFrame : 1; // #123261# remember if to set the NameForFrame
446
447 void Create( sal_Bool bHRefOrBase64 );
448
449 public:
450
451 TYPEINFO();
452
453 sal_Bool CreateIfNotThere();
GetHRef() const454 const OUString& GetHRef() const { return sHRef; }
455
456 XMLTextFrameContext_Impl( SvXMLImport& rImport,
457 sal_uInt16 nPrfx,
458 const ::rtl::OUString& rLName,
459 const ::com::sun::star::uno::Reference<
460 ::com::sun::star::xml::sax::XAttributeList > & rAttrList,
461 ::com::sun::star::text::TextContentAnchorType eAnchorType,
462 sal_uInt16 nType,
463 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList,
464 bool bSetNameForFrame); // #123261# control if to set the NameForFrame
465 virtual ~XMLTextFrameContext_Impl();
466
467 virtual void EndElement();
468
469 virtual void Characters( const ::rtl::OUString& rChars );
470
471 SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
472 const ::rtl::OUString& rLocalName,
473 const ::com::sun::star::uno::Reference<
474 ::com::sun::star::xml::sax::XAttributeList > & xAttrList );
475
476 void SetHyperlink( const ::rtl::OUString& rHRef,
477 const ::rtl::OUString& rName,
478 const ::rtl::OUString& rTargetFrameName,
479 sal_Bool bMap );
480 // --> OD 2009-07-22 #i73249#
481 void SetTitle( const ::rtl::OUString& rTitle );
482 // <--
483 void SetDesc( const ::rtl::OUString& rDesc );
484
GetAnchorType() const485 ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
486
487 const ::com::sun::star::uno::Reference <
GetPropSet() const488 ::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
489
490 // #123261# helper to set the NameForFrame
491 void SetNameForFrameFromPropSet();
492 };
493
494 TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
495
SetNameForFrameFromPropSet()496 void XMLTextFrameContext_Impl::SetNameForFrameFromPropSet()
497 {
498 // set name
499 UniReference < XMLTextImportHelper > xTextImportHelper = GetImport().GetTextImport();
500 Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
501
502 if( xNamed.is() && xTextImportHelper.is() )
503 {
504 OUString sOrigName( xNamed->getName() );
505 if( !sOrigName.getLength() ||
506 (sName.getLength() && sOrigName != sName) )
507 {
508 OUString sOldName( sName );
509 sal_Int32 i = 0;
510 while( xTextImportHelper->HasFrameByName( sName ) )
511 {
512 sName = sOldName;
513 sName += OUString::valueOf( ++i );
514 }
515 xNamed->setName( sName );
516 if( sName != sOldName )
517 xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
518 sOldName, sName );
519 }
520 }
521 }
522
Create(sal_Bool)523 void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
524 {
525 UniReference < XMLTextImportHelper > xTextImportHelper =
526 GetImport().GetTextImport();
527
528 switch ( nType)
529 {
530 case XML_TEXT_FRAME_OBJECT:
531 case XML_TEXT_FRAME_OBJECT_OLE:
532 if( xBase64Stream.is() )
533 {
534 OUString sURL( GetImport().ResolveEmbeddedObjectURLFromBase64() );
535 if( sURL.getLength() )
536 xPropSet = GetImport().GetTextImport()
537 ->createAndInsertOLEObject( GetImport(), sURL,
538 sStyleName,
539 sTblName,
540 nWidth, nHeight );
541 }
542 else if( sHRef.getLength() )
543 {
544 OUString sURL( GetImport().ResolveEmbeddedObjectURL( sHRef,
545 OUString() ) );
546
547 if( GetImport().IsPackageURL( sHRef ) )
548 {
549 xPropSet = GetImport().GetTextImport()
550 ->createAndInsertOLEObject( GetImport(), sURL,
551 sStyleName,
552 sTblName,
553 nWidth, nHeight );
554 }
555 else
556 {
557 // it should be an own OOo link that has no storage persistance
558 xPropSet = GetImport().GetTextImport()
559 ->createAndInsertOOoLink( GetImport(),
560 sURL,
561 sStyleName,
562 sTblName,
563 nWidth, nHeight );
564 }
565 }
566 else
567 {
568 OUString sURL( RTL_CONSTASCII_USTRINGPARAM("vnd.sun.star.ServiceName:") );
569 sURL += sFilterService;
570 xPropSet = GetImport().GetTextImport()
571 ->createAndInsertOLEObject( GetImport(), sURL,
572 sStyleName,
573 sTblName,
574 nWidth, nHeight );
575
576 }
577 break;
578 case XML_TEXT_FRAME_APPLET:
579 {
580 xPropSet = GetImport().GetTextImport()
581 ->createAndInsertApplet( sAppletName, sCode,
582 bMayScript, sHRef,
583 nWidth, nHeight);
584 break;
585 }
586 case XML_TEXT_FRAME_PLUGIN:
587 {
588 if(sHRef.getLength())
589 GetImport().GetAbsoluteReference(sHRef);
590 xPropSet = GetImport().GetTextImport()
591 ->createAndInsertPlugin( sMimeType, sHRef,
592 nWidth, nHeight);
593
594 break;
595 }
596 case XML_TEXT_FRAME_FLOATING_FRAME:
597 {
598 xPropSet = GetImport().GetTextImport()
599 ->createAndInsertFloatingFrame( sFrameName, sHRef,
600 sStyleName,
601 nWidth, nHeight);
602 break;
603 }
604 default:
605 {
606 Reference<XMultiServiceFactory> xFactory( GetImport().GetModel(),
607 UNO_QUERY );
608 if( xFactory.is() )
609 {
610 OUString sServiceName;
611 switch( nType )
612 {
613 case XML_TEXT_FRAME_TEXTBOX: sServiceName = sTextBoxServiceName; break;
614 case XML_TEXT_FRAME_GRAPHIC: sServiceName = sGraphicServiceName; break;
615 }
616 Reference<XInterface> xIfc = xFactory->createInstance( sServiceName );
617 DBG_ASSERT( xIfc.is(), "couldn't create frame" );
618 if( xIfc.is() )
619 xPropSet = Reference < XPropertySet >( xIfc, UNO_QUERY );
620 }
621 }
622 }
623
624 if( !xPropSet.is() )
625 {
626 bCreateFailed = sal_True;
627 return;
628 }
629
630 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
631
632 // #123261# set name, but only if wanted, e.g. for MultiImageSupport, it will be set after
633 // it is decided which image will be used. This is done e.g. to avoid double stuff and effects
634 // for the target to avoid double names
635 if(mbSetNameForFrame)
636 {
637 SetNameForFrameFromPropSet();
638 }
639
640 // frame style
641 XMLPropStyleContext *pStyle = 0;
642 if( sStyleName.getLength() )
643 {
644 pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
645 if( pStyle )
646 sStyleName = pStyle->GetParentName();
647 }
648
649 Any aAny;
650 if( sStyleName.getLength() )
651 {
652 OUString sDisplayStyleName( GetImport().GetStyleDisplayName(
653 XML_STYLE_FAMILY_SD_GRAPHICS_ID, sStyleName ) );
654 const Reference < XNameContainer > & rStyles =
655 xTextImportHelper->GetFrameStyles();
656 if( rStyles.is() &&
657 rStyles->hasByName( sDisplayStyleName ) )
658 {
659 aAny <<= sDisplayStyleName;
660 xPropSet->setPropertyValue( sFrameStyleName, aAny );
661 }
662 }
663
664 // anchor type (must be set before any other properties, because
665 // otherwise some orientations cannot be set or will be changed
666 // afterwards)
667 aAny <<= eAnchorType;
668 xPropSet->setPropertyValue( sAnchorType, aAny );
669
670 // hard properties
671 if( pStyle )
672 pStyle->FillPropertySet( xPropSet );
673
674
675 // x and y
676 sal_Int16 nHoriOrient = HoriOrientation::NONE;
677 aAny = xPropSet->getPropertyValue( sHoriOrient );
678 aAny >>= nHoriOrient;
679 if( HoriOrientation::NONE == nHoriOrient )
680 {
681 aAny <<= nX;
682 xPropSet->setPropertyValue( sHoriOrientPosition, aAny );
683 }
684
685 sal_Int16 nVertOrient = VertOrientation::NONE;
686 aAny = xPropSet->getPropertyValue( sVertOrient );
687 aAny >>= nVertOrient;
688 if( VertOrientation::NONE == nVertOrient )
689 {
690 aAny <<= nY;
691 xPropSet->setPropertyValue( sVertOrientPosition, aAny );
692 }
693
694 // width
695 if( nWidth > 0 )
696 {
697 aAny <<= nWidth;
698 xPropSet->setPropertyValue( sWidth, aAny );
699 }
700 if( nRelWidth > 0 || nWidth > 0 )
701 {
702 aAny <<= nRelWidth;
703 xPropSet->setPropertyValue( sRelativeWidth, aAny );
704 }
705 if( bSyncWidth || nWidth > 0 )
706 {
707 sal_Bool bTmp = bSyncWidth;
708 aAny.setValue( &bTmp, ::getBooleanCppuType() );
709 xPropSet->setPropertyValue( sIsSyncWidthToHeight, aAny );
710 }
711 if( xPropSetInfo->hasPropertyByName( sWidthType ) &&
712 (bMinWidth || nWidth > 0 || nRelWidth > 0 ) )
713 {
714 sal_Int16 nSizeType =
715 (bMinWidth && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
716 : SizeType::FIX;
717 aAny <<= nSizeType;
718 xPropSet->setPropertyValue( sWidthType, aAny );
719 }
720
721 if( nHeight > 0 )
722 {
723 aAny <<= nHeight;
724 xPropSet->setPropertyValue( sHeight, aAny );
725 }
726 if( nRelHeight > 0 || nHeight > 0 )
727 {
728 aAny <<= nRelHeight;
729 xPropSet->setPropertyValue( sRelativeHeight, aAny );
730 }
731 if( bSyncHeight || nHeight > 0 )
732 {
733 sal_Bool bTmp = bSyncHeight;
734 aAny.setValue( &bTmp, ::getBooleanCppuType() );
735 xPropSet->setPropertyValue( sIsSyncHeightToWidth, aAny );
736 }
737 if( xPropSetInfo->hasPropertyByName( sSizeType ) &&
738 (bMinHeight || nHeight > 0 || nRelHeight > 0 ) )
739 {
740 sal_Int16 nSizeType =
741 (bMinHeight && XML_TEXT_FRAME_TEXTBOX == nType) ? SizeType::MIN
742 : SizeType::FIX;
743 aAny <<= nSizeType;
744 xPropSet->setPropertyValue( sSizeType, aAny );
745 }
746
747 if( XML_TEXT_FRAME_GRAPHIC == nType )
748 {
749 // URL
750 OSL_ENSURE( sHRef.getLength() > 0 || xBase64Stream.is(),
751 "neither URL nor base64 image data given" );
752 UniReference < XMLTextImportHelper > xTxtImport =
753 GetImport().GetTextImport();
754 if( sHRef.getLength() )
755 {
756 sal_Bool bForceLoad = xTxtImport->IsInsertMode() ||
757 xTxtImport->IsBlockMode() ||
758 xTxtImport->IsStylesOnlyMode() ||
759 xTxtImport->IsOrganizerMode();
760 sHRef = GetImport().ResolveGraphicObjectURL( sHRef, !bForceLoad );
761 }
762 else if( xBase64Stream.is() )
763 {
764 sHRef = GetImport().ResolveGraphicObjectURLFromBase64( xBase64Stream );
765 xBase64Stream = 0;
766 }
767 aAny <<= sHRef;
768 xPropSet->setPropertyValue( sGraphicURL, aAny );
769
770 // filter name
771 aAny <<=sFilterName;
772 xPropSet->setPropertyValue( sGraphicFilter, aAny );
773
774 // rotation
775 aAny <<= nRotation;
776 xPropSet->setPropertyValue( sGraphicRotation, aAny );
777 }
778
779 // page number (must be set after the frame is inserted, because it
780 // will be overwritten then inserting the frame.
781 if( TextContentAnchorType_AT_PAGE == eAnchorType && nPage > 0 )
782 {
783 aAny <<= nPage;
784 xPropSet->setPropertyValue( sAnchorPageNo, aAny );
785 }
786
787 if( XML_TEXT_FRAME_OBJECT != nType &&
788 XML_TEXT_FRAME_OBJECT_OLE != nType &&
789 XML_TEXT_FRAME_APPLET != nType &&
790 XML_TEXT_FRAME_PLUGIN!= nType &&
791 XML_TEXT_FRAME_FLOATING_FRAME != nType)
792 {
793 Reference < XTextContent > xTxtCntnt( xPropSet, UNO_QUERY );
794 xTextImportHelper->InsertTextContent( xTxtCntnt );
795 }
796
797 // #107848#
798 // Make adding the shepe to Z-Ordering dependent from if we are
799 // inside a inside_deleted_section (redlining). That is necessary
800 // since the shape will be removed again later. It would lead to
801 // errors if it would stay inside the Z-Ordering. Thus, the
802 // easiest way to solve that conflict is to not add it here.
803 if(!GetImport().HasTextImport()
804 || !GetImport().GetTextImport()->IsInsideDeleteContext())
805 {
806 Reference < XShape > xShape( xPropSet, UNO_QUERY );
807
808 GetImport().GetShapeImport()->shapeWithZIndexAdded( xShape, nZIndex );
809 }
810
811 if( XML_TEXT_FRAME_TEXTBOX == nType )
812 {
813 xTextImportHelper->ConnectFrameChains( sName, sNextName, xPropSet );
814 Reference < XTextFrame > xTxtFrame( xPropSet, UNO_QUERY );
815 Reference < XText > xTxt = xTxtFrame->getText();
816 xOldTextCursor = xTextImportHelper->GetCursor();
817 xTextImportHelper->SetCursor( xTxt->createTextCursor() );
818
819 // remember old list item and block (#89892#) and reset them
820 // for the text frame
821 xTextImportHelper->PushListContext();
822 mbListContextPushed = true;
823 }
824 }
825
CreateIfNotThere()826 sal_Bool XMLTextFrameContext_Impl::CreateIfNotThere()
827 {
828 if( !xPropSet.is() &&
829 ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
830 XML_TEXT_FRAME_GRAPHIC == nType ) &&
831 xBase64Stream.is() && !bCreateFailed )
832 {
833 if( bOwnBase64Stream )
834 xBase64Stream->closeOutput();
835 Create( sal_True );
836 }
837
838 return xPropSet.is();
839 }
840
XMLTextFrameContext_Impl(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & rAttrList,TextContentAnchorType eATyp,sal_uInt16 nNewType,const Reference<XAttributeList> & rFrameAttrList,bool bSetNameForFrame)841 XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
842 SvXMLImport& rImport,
843 sal_uInt16 nPrfx, const OUString& rLName,
844 const Reference< XAttributeList > & rAttrList,
845 TextContentAnchorType eATyp,
846 sal_uInt16 nNewType,
847 const Reference< XAttributeList > & rFrameAttrList,
848 bool bSetNameForFrame)
849 : SvXMLImportContext( rImport, nPrfx, rLName )
850 , mbListContextPushed( false )
851 , sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
852 , sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
853 , sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
854 , sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
855 , sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
856 , sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
857 , sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
858 , sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
859 , sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
860 , sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
861 , sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
862 , sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
863 , sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
864 , sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
865 , sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
866 , sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
867 , sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
868 // --> OD 2009-07-22 #i73249#
869 //, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
870 , sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
871 , sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
872 // <--
873 , sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
874 , sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
875 , sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
876 , sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
877 , nType( nNewType )
878 , eAnchorType( eATyp )
879 , mbSetNameForFrame(bSetNameForFrame)
880 {
881 nX = 0;
882 nY = 0;
883 nWidth = 0;
884 nHeight = 0;
885 nZIndex = -1;
886 nPage = 0;
887 nRotation = 0;
888 nRelWidth = 0;
889 nRelHeight = 0;
890 bMayScript = sal_False;
891
892 bMinHeight = sal_False;
893 bMinWidth = sal_False;
894 bSyncWidth = sal_False;
895 bSyncHeight = sal_False;
896 bCreateFailed = sal_False;
897 bOwnBase64Stream = sal_False;
898
899 UniReference < XMLTextImportHelper > xTxtImport =
900 GetImport().GetTextImport();
901 const SvXMLTokenMap& rTokenMap =
902 xTxtImport->GetTextFrameAttrTokenMap();
903
904 sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
905 sal_Int16 nTotalAttrCount = nAttrCount + (rFrameAttrList.is() ? rFrameAttrList->getLength() : 0);
906 for( sal_Int16 i=0; i < nTotalAttrCount; i++ )
907 {
908 const OUString& rAttrName =
909 i < nAttrCount ? rAttrList->getNameByIndex( i ) : rFrameAttrList->getNameByIndex( i-nAttrCount );
910 const OUString& rValue =
911 i < nAttrCount ? rAttrList->getValueByIndex( i ): rFrameAttrList->getValueByIndex( i-nAttrCount );
912
913 OUString aLocalName;
914 sal_uInt16 nPrefix =
915 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName,
916 &aLocalName );
917 switch( rTokenMap.Get( nPrefix, aLocalName ) )
918 {
919 case XML_TOK_TEXT_FRAME_STYLE_NAME:
920 sStyleName = rValue;
921 break;
922 case XML_TOK_TEXT_FRAME_NAME:
923 sName = rValue;
924 break;
925 case XML_TOK_TEXT_FRAME_FRAME_NAME:
926 sFrameName = rValue;
927 break;
928 case XML_TOK_TEXT_FRAME_APPLET_NAME:
929 sAppletName = rValue;
930 break;
931 case XML_TOK_TEXT_FRAME_ANCHOR_TYPE:
932 if( TextContentAnchorType_AT_PARAGRAPH == eAnchorType ||
933 TextContentAnchorType_AT_CHARACTER == eAnchorType ||
934 TextContentAnchorType_AS_CHARACTER == eAnchorType )
935 {
936
937 TextContentAnchorType eNew;
938 if( XMLAnchorTypePropHdl::convert( rValue, eNew ) &&
939 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
940 TextContentAnchorType_AT_CHARACTER == eNew ||
941 TextContentAnchorType_AS_CHARACTER == eNew ||
942 TextContentAnchorType_AT_PAGE == eNew) )
943 eAnchorType = eNew;
944 }
945 break;
946 case XML_TOK_TEXT_FRAME_ANCHOR_PAGE_NUMBER:
947 {
948 sal_Int32 nTmp;
949 if( GetImport().GetMM100UnitConverter().
950 convertNumber( nTmp, rValue, 1, SHRT_MAX ) )
951 nPage = (sal_Int16)nTmp;
952 }
953 break;
954 case XML_TOK_TEXT_FRAME_X:
955 GetImport().GetMM100UnitConverter().convertMeasure( nX, rValue );
956 break;
957 case XML_TOK_TEXT_FRAME_Y:
958 GetImport().GetMM100UnitConverter().convertMeasure( nY, rValue );
959 break;
960 case XML_TOK_TEXT_FRAME_WIDTH:
961 // relative widths are obsolete since SRC617. Remove them some day!
962 if( rValue.indexOf( '%' ) != -1 )
963 {
964 sal_Int32 nTmp;
965 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
966 rValue );
967 nRelWidth = (sal_Int16)nTmp;
968 }
969 else
970 {
971 GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
972 rValue, 0 );
973 }
974 break;
975 case XML_TOK_TEXT_FRAME_REL_WIDTH:
976 if( IsXMLToken(rValue, XML_SCALE) )
977 {
978 bSyncWidth = sal_True;
979 }
980 else
981 {
982 sal_Int32 nTmp;
983 if( GetImport().GetMM100UnitConverter().
984 convertPercent( nTmp, rValue ) )
985 nRelWidth = (sal_Int16)nTmp;
986 }
987 break;
988 case XML_TOK_TEXT_FRAME_MIN_WIDTH:
989 if( rValue.indexOf( '%' ) != -1 )
990 {
991 sal_Int32 nTmp;
992 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
993 rValue );
994 nRelWidth = (sal_Int16)nTmp;
995 }
996 else
997 {
998 GetImport().GetMM100UnitConverter().convertMeasure( nWidth,
999 rValue, 0 );
1000 }
1001 bMinWidth = sal_True;
1002 break;
1003 case XML_TOK_TEXT_FRAME_HEIGHT:
1004 // relative heights are obsolete since SRC617. Remove them some day!
1005 if( rValue.indexOf( '%' ) != -1 )
1006 {
1007 sal_Int32 nTmp;
1008 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
1009 rValue );
1010 nRelHeight = (sal_Int16)nTmp;
1011 }
1012 else
1013 {
1014 GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
1015 rValue, 0 );
1016 }
1017 break;
1018 case XML_TOK_TEXT_FRAME_REL_HEIGHT:
1019 if( IsXMLToken( rValue, XML_SCALE ) )
1020 {
1021 bSyncHeight = sal_True;
1022 }
1023 else if( IsXMLToken( rValue, XML_SCALE_MIN ) )
1024 {
1025 bSyncHeight = sal_True;
1026 bMinHeight = sal_True;
1027 }
1028 else
1029 {
1030 sal_Int32 nTmp;
1031 if( GetImport().GetMM100UnitConverter().
1032 convertPercent( nTmp, rValue ) )
1033 nRelHeight = (sal_Int16)nTmp;
1034 }
1035 break;
1036 case XML_TOK_TEXT_FRAME_MIN_HEIGHT:
1037 if( rValue.indexOf( '%' ) != -1 )
1038 {
1039 sal_Int32 nTmp;
1040 GetImport().GetMM100UnitConverter().convertPercent( nTmp,
1041 rValue );
1042 nRelHeight = (sal_Int16)nTmp;
1043 }
1044 else
1045 {
1046 GetImport().GetMM100UnitConverter().convertMeasure( nHeight,
1047 rValue, 0 );
1048 }
1049 bMinHeight = sal_True;
1050 break;
1051 case XML_TOK_TEXT_FRAME_Z_INDEX:
1052 GetImport().GetMM100UnitConverter().convertNumber( nZIndex, rValue, -1 );
1053 break;
1054 case XML_TOK_TEXT_FRAME_NEXT_CHAIN_NAME:
1055 sNextName = rValue;
1056 break;
1057 case XML_TOK_TEXT_FRAME_HREF:
1058 sHRef = rValue;
1059 break;
1060 case XML_TOK_TEXT_FRAME_FILTER_NAME:
1061 sFilterName = rValue;
1062 break;
1063 case XML_TOK_TEXT_FRAME_TRANSFORM:
1064 {
1065 OUString sValue( rValue );
1066 sValue.trim();
1067 const OUString aRotate(GetXMLToken(XML_ROTATE));
1068 const sal_Int32 nRotateLen(aRotate.getLength());
1069 sal_Int32 nLen = sValue.getLength();
1070 if( nLen >= nRotateLen+3 &&
1071 0 == sValue.compareTo( aRotate, nRotateLen ) &&
1072 '(' == sValue[nRotateLen] &&
1073 ')' == sValue[nLen-1] )
1074 {
1075 sValue = sValue.copy( nRotateLen+1, nLen-(nRotateLen+2) );
1076 sValue.trim();
1077 sal_Int32 nVal;
1078 if( GetImport().GetMM100UnitConverter().convertNumber( nVal, sValue ) )
1079 nRotation = (sal_Int16)(nVal % 360 );
1080 }
1081 }
1082 break;
1083 case XML_TOK_TEXT_FRAME_CODE:
1084 sCode = rValue;
1085 break;
1086 case XML_TOK_TEXT_FRAME_OBJECT:
1087 sObject = rValue;
1088 break;
1089 case XML_TOK_TEXT_FRAME_ARCHIVE:
1090 sArchive = rValue;
1091 break;
1092 case XML_TOK_TEXT_FRAME_MAY_SCRIPT:
1093 bMayScript = IsXMLToken( rValue, XML_TRUE );
1094 break;
1095 case XML_TOK_TEXT_FRAME_MIME_TYPE:
1096 sMimeType = rValue;
1097 break;
1098 case XML_TOK_TEXT_FRAME_NOTIFY_ON_UPDATE:
1099 sTblName = rValue;
1100 break;
1101 }
1102 }
1103
1104 if( ( (XML_TEXT_FRAME_GRAPHIC == nType ||
1105 XML_TEXT_FRAME_OBJECT == nType ||
1106 XML_TEXT_FRAME_OBJECT_OLE == nType) &&
1107 !sHRef.getLength() ) ||
1108 ( XML_TEXT_FRAME_APPLET == nType && !sCode.getLength() ) ||
1109 ( XML_TEXT_FRAME_PLUGIN == nType &&
1110 sHRef.getLength() == 0 && sMimeType.getLength() == 0 ) )
1111 return; // no URL: no image or OLE object
1112
1113 Create( sal_True );
1114 }
1115
~XMLTextFrameContext_Impl()1116 XMLTextFrameContext_Impl::~XMLTextFrameContext_Impl()
1117 {
1118 }
1119
EndElement()1120 void XMLTextFrameContext_Impl::EndElement()
1121 {
1122 CreateIfNotThere();
1123
1124 if( xOldTextCursor.is() )
1125 {
1126 GetImport().GetTextImport()->DeleteParagraph();
1127 GetImport().GetTextImport()->SetCursor( xOldTextCursor );
1128 }
1129
1130 // reinstall old list item (if necessary) #89892#
1131 if (mbListContextPushed) {
1132 GetImport().GetTextImport()->PopListContext();
1133 }
1134
1135 if (( nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN ) && xPropSet.is())
1136 GetImport().GetTextImport()->endAppletOrPlugin( xPropSet, aParamMap);
1137 }
1138
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)1139 SvXMLImportContext *XMLTextFrameContext_Impl::CreateChildContext(
1140 sal_uInt16 nPrefix,
1141 const OUString& rLocalName,
1142 const Reference< XAttributeList > & xAttrList )
1143 {
1144 SvXMLImportContext *pContext = 0;
1145
1146 if( XML_NAMESPACE_DRAW == nPrefix )
1147 {
1148 if ( (nType == XML_TEXT_FRAME_APPLET || nType == XML_TEXT_FRAME_PLUGIN) &&
1149 IsXMLToken( rLocalName, XML_PARAM ) )
1150 {
1151 pContext = new XMLTextFrameParam_Impl( GetImport(),
1152 nPrefix, rLocalName,
1153 xAttrList, nType, aParamMap );
1154 }
1155 }
1156 else if( (XML_NAMESPACE_OFFICE == nPrefix) )
1157 {
1158 if( IsXMLToken( rLocalName, XML_BINARY_DATA ) )
1159 {
1160 if( !xPropSet.is() && !xBase64Stream.is() && !bCreateFailed )
1161 {
1162 switch( nType )
1163 {
1164 case XML_TEXT_FRAME_GRAPHIC:
1165 xBase64Stream =
1166 GetImport().GetStreamForGraphicObjectURLFromBase64();
1167 break;
1168 case XML_TEXT_FRAME_OBJECT_OLE:
1169 xBase64Stream =
1170 GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1171 break;
1172 }
1173 if( xBase64Stream.is() )
1174 pContext = new XMLBase64ImportContext( GetImport(), nPrefix,
1175 rLocalName, xAttrList,
1176 xBase64Stream );
1177 }
1178 }
1179 }
1180 // --> OD 2009-08-17 #i100480#
1181 // correction of condition which also avoids warnings.
1182 if( !pContext &&
1183 ( XML_TEXT_FRAME_OBJECT == nType &&
1184 ( ( XML_NAMESPACE_OFFICE == nPrefix &&
1185 IsXMLToken( rLocalName, XML_DOCUMENT ) ) ||
1186 ( XML_NAMESPACE_MATH == nPrefix &&
1187 IsXMLToken( rLocalName, XML_MATH ) ) ) ) )
1188 // <--
1189 {
1190 if( !xPropSet.is() && !bCreateFailed )
1191 {
1192 XMLEmbeddedObjectImportContext *pEContext =
1193 new XMLEmbeddedObjectImportContext( GetImport(), nPrefix,
1194 rLocalName, xAttrList );
1195 sFilterService = pEContext->GetFilterServiceName();
1196 if( sFilterService.getLength() != 0 )
1197 {
1198 Create( sal_False );
1199 if( xPropSet.is() )
1200 {
1201 Reference < XEmbeddedObjectSupplier > xEOS( xPropSet,
1202 UNO_QUERY );
1203 OSL_ENSURE( xEOS.is(),
1204 "no embedded object supplier for own object" );
1205 Reference<com::sun::star::lang::XComponent> aXComponent(xEOS->getEmbeddedObject());
1206 pEContext->SetComponent( aXComponent );
1207 }
1208 }
1209 pContext = pEContext;
1210 }
1211 }
1212 if( !pContext && xOldTextCursor.is() ) // text-box
1213 pContext = GetImport().GetTextImport()->CreateTextChildContext(
1214 GetImport(), nPrefix, rLocalName, xAttrList,
1215 XML_TEXT_TYPE_TEXTBOX );
1216
1217 if( !pContext )
1218 pContext = new SvXMLImportContext( GetImport(), nPrefix, rLocalName );
1219
1220 return pContext;
1221 }
1222
Characters(const OUString & rChars)1223 void XMLTextFrameContext_Impl::Characters( const OUString& rChars )
1224 {
1225 if( ( XML_TEXT_FRAME_OBJECT_OLE == nType ||
1226 XML_TEXT_FRAME_GRAPHIC == nType) &&
1227 !xPropSet.is() && !bCreateFailed )
1228 {
1229 OUString sTrimmedChars( rChars. trim() );
1230 if( sTrimmedChars.getLength() )
1231 {
1232 if( !xBase64Stream.is() )
1233 {
1234 if( XML_TEXT_FRAME_GRAPHIC == nType )
1235 {
1236 xBase64Stream =
1237 GetImport().GetStreamForGraphicObjectURLFromBase64();
1238 }
1239 else
1240 {
1241 xBase64Stream =
1242 GetImport().GetStreamForEmbeddedObjectURLFromBase64();
1243 }
1244 if( xBase64Stream.is() )
1245 bOwnBase64Stream = sal_True;
1246 }
1247 if( bOwnBase64Stream && xBase64Stream.is() )
1248 {
1249 OUString sChars;
1250 if( !sBase64CharsLeft.isEmpty() )
1251 {
1252 sChars = sBase64CharsLeft;
1253 sChars += sTrimmedChars;
1254 sBase64CharsLeft = OUString();
1255 }
1256 else
1257 {
1258 sChars = sTrimmedChars;
1259 }
1260 Sequence< sal_Int8 > aBuffer( (sChars.getLength() / 4) * 3 );
1261 sal_Int32 nCharsDecoded =
1262 GetImport().GetMM100UnitConverter().
1263 decodeBase64SomeChars( aBuffer, sChars );
1264 xBase64Stream->writeBytes( aBuffer );
1265 if( nCharsDecoded != sChars.getLength() )
1266 sBase64CharsLeft = sChars.copy( nCharsDecoded );
1267 }
1268 }
1269 }
1270 }
1271
SetHyperlink(const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,sal_Bool bMap)1272 void XMLTextFrameContext_Impl::SetHyperlink( const OUString& rHRef,
1273 const OUString& rName,
1274 const OUString& rTargetFrameName,
1275 sal_Bool bMap )
1276 {
1277 static ::rtl::OUString s_HyperLinkURL(
1278 RTL_CONSTASCII_USTRINGPARAM("HyperLinkURL"));
1279 static ::rtl::OUString s_HyperLinkName(
1280 RTL_CONSTASCII_USTRINGPARAM("HyperLinkName"));
1281 static ::rtl::OUString s_HyperLinkTarget(
1282 RTL_CONSTASCII_USTRINGPARAM("HyperLinkTarget"));
1283 static ::rtl::OUString s_ServerMap(
1284 RTL_CONSTASCII_USTRINGPARAM("ServerMap"));
1285 if( !xPropSet.is() )
1286 return;
1287
1288 UniReference< XMLTextImportHelper > xTxtImp = GetImport().GetTextImport();
1289 Reference < XPropertySetInfo > xPropSetInfo =
1290 xPropSet->getPropertySetInfo();
1291 if( !xPropSetInfo.is() ||
1292 !xPropSetInfo->hasPropertyByName(s_HyperLinkURL))
1293 return;
1294
1295 Any aAny;
1296 aAny <<= rHRef;
1297 xPropSet->setPropertyValue( s_HyperLinkURL, aAny );
1298
1299 if (xPropSetInfo->hasPropertyByName(s_HyperLinkName))
1300 {
1301 aAny <<= rName;
1302 xPropSet->setPropertyValue(s_HyperLinkName, aAny);
1303 }
1304
1305 if (xPropSetInfo->hasPropertyByName(s_HyperLinkTarget))
1306 {
1307 aAny <<= rTargetFrameName;
1308 xPropSet->setPropertyValue( s_HyperLinkTarget, aAny );
1309 }
1310
1311 if (xPropSetInfo->hasPropertyByName(s_ServerMap))
1312 {
1313 aAny.setValue( &bMap, ::getBooleanCppuType() );
1314 xPropSet->setPropertyValue(s_ServerMap, aAny);
1315 }
1316 }
1317
1318 // --> OD 2009-07-22 #i73249#
SetTitle(const OUString & rTitle)1319 void XMLTextFrameContext_Impl::SetTitle( const OUString& rTitle )
1320 {
1321 if ( xPropSet.is() )
1322 {
1323 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1324 if( xPropSetInfo->hasPropertyByName( sTitle ) )
1325 {
1326 xPropSet->setPropertyValue( sTitle, makeAny( rTitle ) );
1327 }
1328 }
1329 }
1330
SetDesc(const OUString & rDesc)1331 void XMLTextFrameContext_Impl::SetDesc( const OUString& rDesc )
1332 {
1333 if ( xPropSet.is() )
1334 {
1335 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
1336 if( xPropSetInfo->hasPropertyByName( sDescription ) )
1337 {
1338 xPropSet->setPropertyValue( sDescription, makeAny( rDesc ) );
1339 }
1340 }
1341 }
1342 // <--
1343
1344 //-----------------------------------------------------------------------------------------------------
1345
1346 TYPEINIT1( XMLTextFrameContext, SvXMLImportContext );
1347
removeGraphicFromImportContext(const SvXMLImportContext & rContext) const1348 void XMLTextFrameContext::removeGraphicFromImportContext(const SvXMLImportContext& rContext) const
1349 {
1350 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
1351
1352 if(pXMLTextFrameContext_Impl)
1353 {
1354 try
1355 {
1356 // just dispose to delete
1357 uno::Reference< lang::XComponent > xComp(pXMLTextFrameContext_Impl->GetPropSet(), UNO_QUERY);
1358
1359 if(xComp.is())
1360 {
1361 xComp->dispose();
1362 }
1363 }
1364 catch( uno::Exception& )
1365 {
1366 DBG_ERROR( "Error in cleanup of multiple graphic object import (!)" );
1367 }
1368 }
1369 }
1370
getGraphicURLFromImportContext(const SvXMLImportContext & rContext) const1371 rtl::OUString XMLTextFrameContext::getGraphicURLFromImportContext(const SvXMLImportContext& rContext) const
1372 {
1373 rtl::OUString aRetval;
1374 const XMLTextFrameContext_Impl* pXMLTextFrameContext_Impl = dynamic_cast< const XMLTextFrameContext_Impl* >(&rContext);
1375
1376 if(pXMLTextFrameContext_Impl)
1377 {
1378 return pXMLTextFrameContext_Impl->GetHRef();
1379 }
1380
1381 return aRetval;
1382 }
1383
CreateIfNotThere()1384 sal_Bool XMLTextFrameContext::CreateIfNotThere()
1385 {
1386 sal_Bool bRet = sal_False;
1387 SvXMLImportContext *pContext = &m_xImplContext;
1388 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1389 if( pImpl )
1390 bRet = pImpl->CreateIfNotThere();
1391
1392 return bRet;
1393 }
1394
CreateIfNotThere(::com::sun::star::uno::Reference<::com::sun::star::beans::XPropertySet> & rPropSet)1395 sal_Bool XMLTextFrameContext::CreateIfNotThere( ::com::sun::star::uno::Reference <
1396 ::com::sun::star::beans::XPropertySet >& rPropSet )
1397 {
1398 SvXMLImportContext *pContext = &m_xImplContext;
1399 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1400 if( pImpl )
1401 {
1402 if( pImpl->CreateIfNotThere() )
1403 rPropSet = pImpl->GetPropSet();
1404 }
1405
1406 return rPropSet.is();
1407 }
1408
XMLTextFrameContext(SvXMLImport & rImport,sal_uInt16 nPrfx,const OUString & rLName,const Reference<XAttributeList> & xAttrList,TextContentAnchorType eATyp)1409 XMLTextFrameContext::XMLTextFrameContext(
1410 SvXMLImport& rImport,
1411 sal_uInt16 nPrfx, const OUString& rLName,
1412 const Reference< XAttributeList > & xAttrList,
1413 TextContentAnchorType eATyp )
1414 : SvXMLImportContext( rImport, nPrfx, rLName )
1415 , multiImageImportHelper()
1416 , m_xAttrList( new SvXMLAttributeList( xAttrList ) )
1417 , m_pHyperlink( 0 )
1418 // --> OD 2009-07-22 #i73249#
1419 , m_sTitle()
1420 , m_sDesc()
1421 // <--
1422 , m_eDefaultAnchorType( eATyp )
1423 // --> OD 2006-03-10 #i51726#
1424 , m_HasAutomaticStyleWithoutParentStyle( sal_False )
1425 // <--
1426 , m_bSupportsReplacement( sal_False )
1427 {
1428 sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
1429 for( sal_Int16 i=0; i < nAttrCount; i++ )
1430 {
1431 const OUString& rAttrName = xAttrList->getNameByIndex( i );
1432
1433 OUString aLocalName;
1434 sal_uInt16 nPrefix =
1435 GetImport().GetNamespaceMap().GetKeyByAttrName( rAttrName, &aLocalName );
1436 // --> OD 2006-03-10 #i51726#
1437 // New distinguish attribute between Writer objects and Draw objects is:
1438 // Draw objects have an automatic style without a parent style
1439 if ( XML_NAMESPACE_DRAW == nPrefix &&
1440 IsXMLToken( aLocalName, XML_STYLE_NAME ) )
1441 {
1442 OUString aStyleName = xAttrList->getValueByIndex( i );
1443 if( aStyleName.getLength() )
1444 {
1445 UniReference < XMLTextImportHelper > xTxtImport =
1446 GetImport().GetTextImport();
1447 XMLPropStyleContext* pStyle( 0L );
1448 pStyle = xTxtImport->FindAutoFrameStyle( aStyleName );
1449 if ( pStyle && !pStyle->GetParentName().getLength() )
1450 {
1451 m_HasAutomaticStyleWithoutParentStyle = sal_True;
1452 }
1453 }
1454 }
1455 // <--
1456 else if ( XML_NAMESPACE_TEXT == nPrefix &&
1457 IsXMLToken( aLocalName, XML_ANCHOR_TYPE ) )
1458 {
1459 TextContentAnchorType eNew;
1460 if( XMLAnchorTypePropHdl::convert( xAttrList->getValueByIndex(i),
1461 eNew ) &&
1462 ( TextContentAnchorType_AT_PARAGRAPH == eNew ||
1463 TextContentAnchorType_AT_CHARACTER == eNew ||
1464 TextContentAnchorType_AS_CHARACTER == eNew ||
1465 TextContentAnchorType_AT_PAGE == eNew) )
1466 m_eDefaultAnchorType = eNew;
1467 }
1468 }
1469 }
1470
~XMLTextFrameContext()1471 XMLTextFrameContext::~XMLTextFrameContext()
1472 {
1473 delete m_pHyperlink;
1474 }
1475
EndElement()1476 void XMLTextFrameContext::EndElement()
1477 {
1478 /// solve if multiple image child contexts were imported
1479 /// the winner is returned, if something has yet to be done with it
1480 const SvXMLImportContext* pWinner = solveMultipleImages();
1481
1482 // #123261# see if the winner is a XMLTextFrameContext_Impl
1483 const XMLTextFrameContext_Impl* pImplWinner = dynamic_cast< const XMLTextFrameContext_Impl* >(pWinner);
1484
1485 if(pImplWinner)
1486 {
1487 // #123261# if yes, set name now, after the winner is identified (setting at each
1488 // candidate may run into problems due to colliding with efforts in the target to
1489 // avoid double names, so only set one name at one image and not at each)
1490 const_cast< XMLTextFrameContext_Impl* >(pImplWinner)->SetNameForFrameFromPropSet();
1491 }
1492
1493 SvXMLImportContext *pContext = &m_xImplContext;
1494 XMLTextFrameContext_Impl *pImpl = dynamic_cast< XMLTextFrameContext_Impl* >(pContext);
1495
1496 if( pImpl )
1497 {
1498 pImpl->CreateIfNotThere();
1499
1500 // --> OD 2009-07-22 #i73249#
1501 // // alternative text
1502 // if( m_sDesc.getLength() )
1503 // pImpl->SetDesc( m_sDesc );
1504 // svg:title
1505 if( m_sTitle.getLength() )
1506 {
1507 pImpl->SetTitle( m_sTitle );
1508 }
1509 if( m_sDesc.getLength() )
1510 {
1511 pImpl->SetDesc( m_sDesc );
1512 }
1513 // <--
1514
1515 if( m_pHyperlink )
1516 {
1517 pImpl->SetHyperlink( m_pHyperlink->GetHRef(), m_pHyperlink->GetName(),
1518 m_pHyperlink->GetTargetFrameName(), m_pHyperlink->GetMap() );
1519 delete m_pHyperlink;
1520 m_pHyperlink = 0;
1521 }
1522
1523 }
1524 }
1525
CreateChildContext(sal_uInt16 p_nPrefix,const OUString & rLocalName,const Reference<XAttributeList> & xAttrList)1526 SvXMLImportContext *XMLTextFrameContext::CreateChildContext(
1527 sal_uInt16 p_nPrefix,
1528 const OUString& rLocalName,
1529 const Reference< XAttributeList > & xAttrList )
1530 {
1531 SvXMLImportContext *pContext = 0;
1532
1533 if( !m_xImplContext.Is() )
1534 {
1535 // no child exists
1536 if( XML_NAMESPACE_DRAW == p_nPrefix )
1537 {
1538 sal_uInt16 nFrameType = USHRT_MAX;
1539 if( IsXMLToken( rLocalName, XML_TEXT_BOX ) )
1540 nFrameType = XML_TEXT_FRAME_TEXTBOX;
1541 else if( IsXMLToken( rLocalName, XML_IMAGE ) )
1542 nFrameType = XML_TEXT_FRAME_GRAPHIC;
1543 else if( IsXMLToken( rLocalName, XML_OBJECT ) )
1544 nFrameType = XML_TEXT_FRAME_OBJECT;
1545 else if( IsXMLToken( rLocalName, XML_OBJECT_OLE ) )
1546 nFrameType = XML_TEXT_FRAME_OBJECT_OLE;
1547 else if( IsXMLToken( rLocalName, XML_APPLET) )
1548 nFrameType = XML_TEXT_FRAME_APPLET;
1549 else if( IsXMLToken( rLocalName, XML_PLUGIN ) )
1550 nFrameType = XML_TEXT_FRAME_PLUGIN;
1551 else if( IsXMLToken( rLocalName, XML_FLOATING_FRAME ) )
1552 nFrameType = XML_TEXT_FRAME_FLOATING_FRAME;
1553
1554 if( USHRT_MAX != nFrameType )
1555 {
1556 // --> OD 2006-03-10 #i51726#
1557 if ( ( XML_TEXT_FRAME_TEXTBOX == nFrameType ||
1558 XML_TEXT_FRAME_GRAPHIC == nFrameType ) &&
1559 m_HasAutomaticStyleWithoutParentStyle )
1560 // <--
1561 {
1562 Reference < XShapes > xShapes;
1563 pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1564 GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1565 }
1566 else if( XML_TEXT_FRAME_PLUGIN == nFrameType )
1567 {
1568 bool bMedia = false;
1569
1570 // check, if we have a media object
1571 for( sal_Int16 n = 0, nAttrCount = ( xAttrList.is() ? xAttrList->getLength() : 0 ); n < nAttrCount; ++n )
1572 {
1573 OUString aLocalName;
1574 sal_uInt16 nPrefix = GetImport().GetNamespaceMap().GetKeyByAttrName( xAttrList->getNameByIndex( n ), &aLocalName );
1575
1576 if( nPrefix == XML_NAMESPACE_DRAW && IsXMLToken( aLocalName, XML_MIME_TYPE ) )
1577 {
1578 if( 0 == xAttrList->getValueByIndex( n ).compareToAscii( "application/vnd.sun.star.media" ) )
1579 bMedia = true;
1580
1581 // leave this loop
1582 n = nAttrCount - 1;
1583 }
1584 }
1585
1586 if( bMedia )
1587 {
1588 Reference < XShapes > xShapes;
1589 pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1590 GetImport(), p_nPrefix, rLocalName, xAttrList, xShapes, m_xAttrList );
1591 }
1592 }
1593 else if( XML_TEXT_FRAME_OBJECT == nFrameType ||
1594 XML_TEXT_FRAME_OBJECT_OLE == nFrameType )
1595 {
1596 m_bSupportsReplacement = sal_True;
1597 }
1598 else if(XML_TEXT_FRAME_GRAPHIC == nFrameType)
1599 {
1600 setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
1601 }
1602
1603 if( !pContext )
1604 {
1605 pContext = new XMLTextFrameContext_Impl(
1606 GetImport(),
1607 p_nPrefix,
1608 rLocalName,
1609 xAttrList,
1610 m_eDefaultAnchorType,
1611 nFrameType,
1612 m_xAttrList,
1613 !getSupportsMultipleContents());
1614 }
1615
1616 m_xImplContext = pContext;
1617
1618 if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType)
1619 {
1620 addContent(*m_xImplContext);
1621 }
1622 }
1623 }
1624 }
1625 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
1626 {
1627 // read another image
1628 pContext = new XMLTextFrameContext_Impl(
1629 GetImport(),
1630 p_nPrefix,
1631 rLocalName,
1632 xAttrList,
1633 m_eDefaultAnchorType,
1634 XML_TEXT_FRAME_GRAPHIC,
1635 m_xAttrList,
1636 false);
1637
1638 m_xImplContext = pContext;
1639 addContent(*m_xImplContext);
1640 }
1641 else if( m_bSupportsReplacement && !m_xReplImplContext &&
1642 XML_NAMESPACE_DRAW == p_nPrefix &&
1643 IsXMLToken( rLocalName, XML_IMAGE ) )
1644 {
1645 // read replacement image
1646 Reference < XPropertySet > xPropSet;
1647 if( CreateIfNotThere( xPropSet ) )
1648 {
1649 pContext = new XMLReplacementImageContext( GetImport(),
1650 p_nPrefix, rLocalName, xAttrList, xPropSet );
1651 m_xReplImplContext = pContext;
1652 }
1653 }
1654 else if( m_xImplContext->ISA( XMLTextFrameContext_Impl ) )
1655 {
1656 // the child is a writer frame
1657 if( XML_NAMESPACE_SVG == p_nPrefix )
1658 {
1659 // --> OD 2009-07-22 #i73249#
1660 // bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1661 // if( IsXMLToken( rLocalName, bOld ? XML_DESC : XML_TITLE ) )
1662 // pContext = new XMLTextFrameDescContext_Impl( GetImport(), p_nPrefix, rLocalName,
1663 // xAttrList, m_sDesc );
1664 const bool bOld = SvXMLImport::OOo_2x >= GetImport().getGeneratorVersion();
1665 if ( bOld )
1666 {
1667 if ( IsXMLToken( rLocalName, XML_DESC ) )
1668 {
1669 pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1670 p_nPrefix,
1671 rLocalName,
1672 m_sTitle );
1673 }
1674 }
1675 else
1676 {
1677 if( IsXMLToken( rLocalName, XML_TITLE ) )
1678 {
1679 pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1680 p_nPrefix,
1681 rLocalName,
1682 m_sTitle );
1683 }
1684 else if ( IsXMLToken( rLocalName, XML_DESC ) )
1685 {
1686 pContext = new XMLTextFrameTitleOrDescContext_Impl( GetImport(),
1687 p_nPrefix,
1688 rLocalName,
1689 m_sDesc );
1690 }
1691 }
1692 // <--
1693 }
1694 else if( XML_NAMESPACE_DRAW == p_nPrefix )
1695 {
1696 Reference < XPropertySet > xPropSet;
1697 if( IsXMLToken( rLocalName, XML_CONTOUR_POLYGON ) )
1698 {
1699 if( CreateIfNotThere( xPropSet ) )
1700 pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1701 xAttrList, xPropSet, sal_False );
1702 }
1703 else if( IsXMLToken( rLocalName, XML_CONTOUR_PATH ) )
1704 {
1705 if( CreateIfNotThere( xPropSet ) )
1706 pContext = new XMLTextFrameContourContext_Impl( GetImport(), p_nPrefix, rLocalName,
1707 xAttrList, xPropSet, sal_True );
1708 }
1709 else if( IsXMLToken( rLocalName, XML_IMAGE_MAP ) )
1710 {
1711 if( CreateIfNotThere( xPropSet ) )
1712 pContext = new XMLImageMapContext( GetImport(), p_nPrefix, rLocalName, xPropSet );
1713 }
1714 }
1715 else if( (XML_NAMESPACE_OFFICE == p_nPrefix) && IsXMLToken( rLocalName, XML_EVENT_LISTENERS ) )
1716 {
1717 // do we still have the frame object?
1718 Reference < XPropertySet > xPropSet;
1719 if( CreateIfNotThere( xPropSet ) )
1720 {
1721 // is it an event supplier?
1722 Reference<XEventsSupplier> xEventsSupplier(xPropSet, UNO_QUERY);
1723 if (xEventsSupplier.is())
1724 {
1725 // OK, we have the events, so create the context
1726 pContext = new XMLEventsImportContext(GetImport(), p_nPrefix,
1727 rLocalName, xEventsSupplier);
1728 }
1729 }
1730 }
1731 }
1732 else if( p_nPrefix == XML_NAMESPACE_SVG && // #i68101#
1733 (IsXMLToken( rLocalName, XML_TITLE ) || IsXMLToken( rLocalName, XML_DESC ) ) )
1734 {
1735 pContext = m_xImplContext->CreateChildContext( p_nPrefix, rLocalName, xAttrList );
1736 }
1737 else
1738 {
1739 // the child is a drawing shape
1740 pContext = GetImport().GetShapeImport()->CreateFrameChildContext(
1741 &m_xImplContext, p_nPrefix, rLocalName, xAttrList );
1742 }
1743
1744 if( !pContext )
1745 pContext = new SvXMLImportContext( GetImport(), p_nPrefix, rLocalName );
1746
1747 return pContext;
1748 }
1749
SetHyperlink(const OUString & rHRef,const OUString & rName,const OUString & rTargetFrameName,sal_Bool bMap)1750 void XMLTextFrameContext::SetHyperlink( const OUString& rHRef,
1751 const OUString& rName,
1752 const OUString& rTargetFrameName,
1753 sal_Bool bMap )
1754 {
1755 OSL_ENSURE( !m_pHyperlink, "recursive SetHyperlink call" );
1756 delete m_pHyperlink;
1757 m_pHyperlink = new XMLTextFrameContextHyperlink_Impl(
1758 rHRef, rName, rTargetFrameName, bMap );
1759 }
1760
GetAnchorType() const1761 TextContentAnchorType XMLTextFrameContext::GetAnchorType() const
1762 {
1763 SvXMLImportContext *pContext = &m_xImplContext;
1764 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1765 if( pImpl )
1766 return pImpl->GetAnchorType();
1767 else
1768 return m_eDefaultAnchorType;
1769 }
1770
GetTextContent() const1771 Reference < XTextContent > XMLTextFrameContext::GetTextContent() const
1772 {
1773 Reference < XTextContent > xTxtCntnt;
1774 SvXMLImportContext *pContext = &m_xImplContext;
1775 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1776 if( pImpl )
1777 xTxtCntnt.set( pImpl->GetPropSet(), UNO_QUERY );
1778
1779 return xTxtCntnt;
1780 }
1781
1782 // --> OD 2004-08-24 #33242#
GetShape() const1783 Reference < XShape > XMLTextFrameContext::GetShape() const
1784 {
1785 Reference < XShape > xShape;
1786 SvXMLImportContext* pContext = &m_xImplContext;
1787 SvXMLShapeContext* pImpl = PTR_CAST( SvXMLShapeContext, pContext );
1788 if ( pImpl )
1789 {
1790 xShape = pImpl->getShape();
1791 }
1792
1793 return xShape;
1794 }
1795 // <--
1796