XMLTextFrameContext.cxx (598d8f9f) XMLTextFrameContext.cxx (011bafbf)
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

--- 411 unchanged lines hidden (view full) ---

420
421 sal_Bool bMayScript : 1;
422 sal_Bool bMinWidth : 1;
423 sal_Bool bMinHeight : 1;
424 sal_Bool bSyncWidth : 1;
425 sal_Bool bSyncHeight : 1;
426 sal_Bool bCreateFailed : 1;
427 sal_Bool bOwnBase64Stream : 1;
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

--- 411 unchanged lines hidden (view full) ---

420
421 sal_Bool bMayScript : 1;
422 sal_Bool bMinWidth : 1;
423 sal_Bool bMinHeight : 1;
424 sal_Bool bSyncWidth : 1;
425 sal_Bool bSyncHeight : 1;
426 sal_Bool bCreateFailed : 1;
427 sal_Bool bOwnBase64Stream : 1;
428 bool mbSetNameForFrame : 1; // #123261# remember if to set the NameForFrame
428
429 void Create( sal_Bool bHRefOrBase64 );
430
431public:
432
433 TYPEINFO();
434
435 sal_Bool CreateIfNotThere();
436 const OUString& GetHRef() const { return sHRef; }
437
429
430 void Create( sal_Bool bHRefOrBase64 );
431
432public:
433
434 TYPEINFO();
435
436 sal_Bool CreateIfNotThere();
437 const OUString& GetHRef() const { return sHRef; }
438
438 XMLTextFrameContext_Impl( SvXMLImport& rImport,
439 sal_uInt16 nPrfx,
440 const ::rtl::OUString& rLName,
441 const ::com::sun::star::uno::Reference<
442 ::com::sun::star::xml::sax::XAttributeList > & rAttrList,
443 ::com::sun::star::text::TextContentAnchorType eAnchorType,
444 sal_uInt16 nType,
445 const ::com::sun::star::uno::Reference<
446 ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList );
447 virtual ~XMLTextFrameContext_Impl();
439 XMLTextFrameContext_Impl( SvXMLImport& rImport,
440 sal_uInt16 nPrfx,
441 const ::rtl::OUString& rLName,
442 const ::com::sun::star::uno::Reference<
443 ::com::sun::star::xml::sax::XAttributeList > & rAttrList,
444 ::com::sun::star::text::TextContentAnchorType eAnchorType,
445 sal_uInt16 nType,
446 const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList,
447 bool bSetNameForFrame); // #123261# control if to set the NameForFrame
448 virtual ~XMLTextFrameContext_Impl();
448
449 virtual void EndElement();
450
451 virtual void Characters( const ::rtl::OUString& rChars );
452
453 SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
454 const ::rtl::OUString& rLocalName,
455 const ::com::sun::star::uno::Reference<

--- 7 unchanged lines hidden (view full) ---

463 void SetTitle( const ::rtl::OUString& rTitle );
464 // <--
465 void SetDesc( const ::rtl::OUString& rDesc );
466
467 ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
468
469 const ::com::sun::star::uno::Reference <
470 ::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
449
450 virtual void EndElement();
451
452 virtual void Characters( const ::rtl::OUString& rChars );
453
454 SvXMLImportContext *CreateChildContext( sal_uInt16 nPrefix,
455 const ::rtl::OUString& rLocalName,
456 const ::com::sun::star::uno::Reference<

--- 7 unchanged lines hidden (view full) ---

464 void SetTitle( const ::rtl::OUString& rTitle );
465 // <--
466 void SetDesc( const ::rtl::OUString& rDesc );
467
468 ::com::sun::star::text::TextContentAnchorType GetAnchorType() const { return eAnchorType; }
469
470 const ::com::sun::star::uno::Reference <
471 ::com::sun::star::beans::XPropertySet >& GetPropSet() const { return xPropSet; }
472
473 // #123261# helper to set the NameForFrame
474 void SetNameForFrameFromPropSet();
471};
472
473TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
474
475};
476
477TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
478
479void XMLTextFrameContext_Impl::SetNameForFrameFromPropSet()
480{
481 // set name
482 UniReference < XMLTextImportHelper > xTextImportHelper = GetImport().GetTextImport();
483 Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
484
485 if( xNamed.is() && xTextImportHelper.is() )
486 {
487 OUString sOrigName( xNamed->getName() );
488 if( !sOrigName.getLength() ||
489 (sName.getLength() && sOrigName != sName) )
490 {
491 OUString sOldName( sName );
492 sal_Int32 i = 0;
493 while( xTextImportHelper->HasFrameByName( sName ) )
494 {
495 sName = sOldName;
496 sName += OUString::valueOf( ++i );
497 }
498 xNamed->setName( sName );
499 if( sName != sOldName )
500 xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
501 sOldName, sName );
502 }
503 }
504}
505
475void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
476{
477 UniReference < XMLTextImportHelper > xTextImportHelper =
478 GetImport().GetTextImport();
479
480 switch ( nType)
481 {
482 case XML_TEXT_FRAME_OBJECT:

--- 93 unchanged lines hidden (view full) ---

576 if( !xPropSet.is() )
577 {
578 bCreateFailed = sal_True;
579 return;
580 }
581
582 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
583
506void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
507{
508 UniReference < XMLTextImportHelper > xTextImportHelper =
509 GetImport().GetTextImport();
510
511 switch ( nType)
512 {
513 case XML_TEXT_FRAME_OBJECT:

--- 93 unchanged lines hidden (view full) ---

607 if( !xPropSet.is() )
608 {
609 bCreateFailed = sal_True;
610 return;
611 }
612
613 Reference< XPropertySetInfo > xPropSetInfo = xPropSet->getPropertySetInfo();
614
584 // set name
585 Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
586 if( xNamed.is() )
587 {
588 OUString sOrigName( xNamed->getName() );
589 if( !sOrigName.getLength() ||
590 (sName.getLength() && sOrigName != sName) )
591 {
592 OUString sOldName( sName );
593 sal_Int32 i = 0;
594 while( xTextImportHelper->HasFrameByName( sName ) )
595 {
596 sName = sOldName;
597 sName += OUString::valueOf( ++i );
598 }
599 xNamed->setName( sName );
600 if( sName != sOldName )
601 xTextImportHelper->GetRenameMap().Add( XML_TEXT_RENAME_TYPE_FRAME,
602 sOldName, sName );
603 }
604 }
615 // #123261# set name, but only if wanted, e.g. for MultiImageSupport, it will be set after
616 // it is decided which image will be used. This is done e.g. to avoid double stuff and effects
617 // for the target to avoid double names
618 if(mbSetNameForFrame)
619 {
620 SetNameForFrameFromPropSet();
621 }
605
606 // frame style
607 XMLPropStyleContext *pStyle = 0;
608 if( sStyleName.getLength() )
609 {
610 pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
611 if( pStyle )
612 sStyleName = pStyle->GetParentName();

--- 187 unchanged lines hidden (view full) ---

800 xBase64Stream->closeOutput();
801 Create( sal_True );
802 }
803
804 return xPropSet.is();
805}
806
807XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
622
623 // frame style
624 XMLPropStyleContext *pStyle = 0;
625 if( sStyleName.getLength() )
626 {
627 pStyle = xTextImportHelper->FindAutoFrameStyle( sStyleName );
628 if( pStyle )
629 sStyleName = pStyle->GetParentName();

--- 187 unchanged lines hidden (view full) ---

817 xBase64Stream->closeOutput();
818 Create( sal_True );
819 }
820
821 return xPropSet.is();
822}
823
824XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
808 SvXMLImport& rImport,
809 sal_uInt16 nPrfx, const OUString& rLName,
810 const Reference< XAttributeList > & rAttrList,
811 TextContentAnchorType eATyp,
812 sal_uInt16 nNewType,
813 const Reference< XAttributeList > & rFrameAttrList )
814: SvXMLImportContext( rImport, nPrfx, rLName )
825 SvXMLImport& rImport,
826 sal_uInt16 nPrfx, const OUString& rLName,
827 const Reference< XAttributeList > & rAttrList,
828 TextContentAnchorType eATyp,
829 sal_uInt16 nNewType,
830 const Reference< XAttributeList > & rFrameAttrList,
831 bool bSetNameForFrame)
832: SvXMLImportContext( rImport, nPrfx, rLName )
815, mbListContextPushed( false )
833, mbListContextPushed( false )
816, sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
817, sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
818, sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
819, sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
820, sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
821, sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
822, sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
823, sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
824, sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
825, sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
826, sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
827, sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
828, sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
829, sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
830, sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
831, sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
832, sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
834, sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
835, sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
836, sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
837, sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
838, sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
839, sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
840, sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
841, sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
842, sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
843, sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
844, sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
845, sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
846, sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
847, sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
848, sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
849, sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
850, sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
833// --> OD 2009-07-22 #i73249#
834//, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
835, sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
836, sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
837// <--
851// --> OD 2009-07-22 #i73249#
852//, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
853, sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
854, sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
855// <--
838, sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
839, sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
840, sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
841, sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
842, nType( nNewType )
843, eAnchorType( eATyp )
856, sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
857, sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
858, sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
859, sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
860, nType( nNewType )
861, eAnchorType( eATyp )
862, mbSetNameForFrame(bSetNameForFrame)
844{
845 nX = 0;
846 nY = 0;
847 nWidth = 0;
848 nHeight = 0;
849 nZIndex = -1;
850 nPage = 0;
851 nRotation = 0;

--- 584 unchanged lines hidden (view full) ---

1436{
1437 delete m_pHyperlink;
1438}
1439
1440void XMLTextFrameContext::EndElement()
1441{
1442 /// solve if multiple image child contexts were imported
1443 /// the winner is returned, if something has yet to be done with it
863{
864 nX = 0;
865 nY = 0;
866 nWidth = 0;
867 nHeight = 0;
868 nZIndex = -1;
869 nPage = 0;
870 nRotation = 0;

--- 584 unchanged lines hidden (view full) ---

1455{
1456 delete m_pHyperlink;
1457}
1458
1459void XMLTextFrameContext::EndElement()
1460{
1461 /// solve if multiple image child contexts were imported
1462 /// the winner is returned, if something has yet to be done with it
1444 /*const SvXMLImportContext* pWinner =*/ solveMultipleImages();
1463 const SvXMLImportContext* pWinner = solveMultipleImages();
1445
1464
1446 SvXMLImportContext *pContext = &m_xImplContext;
1447 XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl, pContext );
1448 if( pImpl )
1449 {
1450 pImpl->CreateIfNotThere();
1465 // #123261# see if the winner is a XMLTextFrameContext_Impl
1466 const XMLTextFrameContext_Impl* pImplWinner = dynamic_cast< const XMLTextFrameContext_Impl* >(pWinner);
1451
1467
1468 if(pImplWinner)
1469 {
1470 // #123261# if yes, set name now, after the winner is identified (setting at each
1471 // candidate may run into problems due to colliding with efforts in the target to
1472 // avoid double names, so only set one name at one image and not at each)
1473 const_cast< XMLTextFrameContext_Impl* >(pImplWinner)->SetNameForFrameFromPropSet();
1474 }
1475
1476 SvXMLImportContext *pContext = &m_xImplContext;
1477 XMLTextFrameContext_Impl *pImpl = dynamic_cast< XMLTextFrameContext_Impl* >(pContext);
1478
1479 if( pImpl )
1480 {
1481 pImpl->CreateIfNotThere();
1482
1452 // --> OD 2009-07-22 #i73249#
1453// // alternative text
1454// if( m_sDesc.getLength() )
1455// pImpl->SetDesc( m_sDesc );
1456 // svg:title
1457 if( m_sTitle.getLength() )
1458 {
1459 pImpl->SetTitle( m_sTitle );

--- 87 unchanged lines hidden (view full) ---

1547 {
1548 m_bSupportsReplacement = sal_True;
1549 }
1550 else if(XML_TEXT_FRAME_GRAPHIC == nFrameType)
1551 {
1552 setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
1553 }
1554
1483 // --> OD 2009-07-22 #i73249#
1484// // alternative text
1485// if( m_sDesc.getLength() )
1486// pImpl->SetDesc( m_sDesc );
1487 // svg:title
1488 if( m_sTitle.getLength() )
1489 {
1490 pImpl->SetTitle( m_sTitle );

--- 87 unchanged lines hidden (view full) ---

1578 {
1579 m_bSupportsReplacement = sal_True;
1580 }
1581 else if(XML_TEXT_FRAME_GRAPHIC == nFrameType)
1582 {
1583 setSupportsMultipleContents(IsXMLToken(rLocalName, XML_IMAGE));
1584 }
1585
1555 if( !pContext )
1556 {
1586 if( !pContext )
1587 {
1588 pContext = new XMLTextFrameContext_Impl(
1589 GetImport(),
1590 p_nPrefix,
1591 rLocalName,
1592 xAttrList,
1593 m_eDefaultAnchorType,
1594 nFrameType,
1595 m_xAttrList,
1596 !getSupportsMultipleContents());
1597 }
1557
1598
1558 pContext = new XMLTextFrameContext_Impl( GetImport(), p_nPrefix,
1559 rLocalName, xAttrList,
1560 m_eDefaultAnchorType,
1561 nFrameType,
1562 m_xAttrList );
1563 }
1599 m_xImplContext = pContext;
1564
1600
1565 m_xImplContext = pContext;
1566
1567 if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType)
1568 {
1569 addContent(*m_xImplContext);
1570 }
1601 if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC == nFrameType)
1602 {
1603 addContent(*m_xImplContext);
1604 }
1571 }
1572 }
1573 }
1605 }
1606 }
1607 }
1574 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
1575 {
1576 // read another image
1577 pContext = new XMLTextFrameContext_Impl(
1608 else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix && IsXMLToken(rLocalName, XML_IMAGE))
1609 {
1610 // read another image
1611 pContext = new XMLTextFrameContext_Impl(
1578 GetImport(), p_nPrefix, rLocalName, xAttrList,
1579 m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList);
1580
1612 GetImport(),
1613 p_nPrefix,
1614 rLocalName,
1615 xAttrList,
1616 m_eDefaultAnchorType,
1617 XML_TEXT_FRAME_GRAPHIC,
1618 m_xAttrList,
1619 false);
1620
1581 m_xImplContext = pContext;
1582 addContent(*m_xImplContext);
1583 }
1584 else if( m_bSupportsReplacement && !m_xReplImplContext &&
1585 XML_NAMESPACE_DRAW == p_nPrefix &&
1586 IsXMLToken( rLocalName, XML_IMAGE ) )
1587 {
1588 // read replacement image

--- 150 unchanged lines hidden ---
1621 m_xImplContext = pContext;
1622 addContent(*m_xImplContext);
1623 }
1624 else if( m_bSupportsReplacement && !m_xReplImplContext &&
1625 XML_NAMESPACE_DRAW == p_nPrefix &&
1626 IsXMLToken( rLocalName, XML_IMAGE ) )
1627 {
1628 // read replacement image

--- 150 unchanged lines hidden ---