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