Author: alg
Date: Tue Sep 17 09:58:39 2013
New Revision: 1523968
URL: http://svn.apache.org/r1523968
Log:
i123261 corrected name clashes on writer graphic import with multi image support
Modified:
openoffice/trunk/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx
openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx
Modified: openoffice/trunk/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx?rev=1523968&r1=1523967&r2=1523968&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx (original)
+++ openoffice/trunk/main/xmloff/inc/xmloff/xmlmultiimagehelper.hxx Tue Sep 17
09:58:39 2013
@@ -40,7 +40,7 @@ protected:
public:
multiImageImportHelper();
- ~multiImageImportHelper();
+ virtual ~multiImageImportHelper();
/// solve multiple imported images. The most valuable one is choosen,
/// see imlementation for evtl. changing weights and/or adding filetypes.
Modified: openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx
URL:
http://svn.apache.org/viewvc/openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx?rev=1523968&r1=1523967&r2=1523968&view=diff
==============================================================================
--- openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx (original)
+++ openoffice/trunk/main/xmloff/source/text/XMLTextFrameContext.cxx Tue Sep 17
09:58:39 2013
@@ -425,6 +425,7 @@ class XMLTextFrameContext_Impl : public
sal_Bool bSyncHeight : 1;
sal_Bool bCreateFailed : 1;
sal_Bool bOwnBase64Stream : 1;
+ bool mbSetNameForFrame : 1; // #123261# remember if to set the
NameForFrame
void Create( sal_Bool bHRefOrBase64 );
@@ -435,16 +436,16 @@ public:
sal_Bool CreateIfNotThere();
const OUString& GetHRef() const { return sHRef; }
- XMLTextFrameContext_Impl( SvXMLImport& rImport,
- sal_uInt16 nPrfx,
- const ::rtl::OUString& rLName,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList > &
rAttrList,
- ::com::sun::star::text::TextContentAnchorType
eAnchorType,
- sal_uInt16 nType,
- const ::com::sun::star::uno::Reference<
- ::com::sun::star::xml::sax::XAttributeList > &
rFrameAttrList );
- virtual ~XMLTextFrameContext_Impl();
+ XMLTextFrameContext_Impl( SvXMLImport& rImport,
+ sal_uInt16 nPrfx,
+ const ::rtl::OUString& rLName,
+ const ::com::sun::star::uno::Reference<
+ ::com::sun::star::xml::sax::XAttributeList > & rAttrList,
+ ::com::sun::star::text::TextContentAnchorType eAnchorType,
+ sal_uInt16 nType,
+ const ::com::sun::star::uno::Reference<
::com::sun::star::xml::sax::XAttributeList > & rFrameAttrList,
+ bool bSetNameForFrame); // #123261# control if to set the NameForFrame
+ virtual ~XMLTextFrameContext_Impl();
virtual void EndElement();
@@ -468,10 +469,40 @@ public:
const ::com::sun::star::uno::Reference <
::com::sun::star::beans::XPropertySet >& GetPropSet() const {
return xPropSet; }
+
+ // #123261# helper to set the NameForFrame
+ void SetNameForFrameFromPropSet();
};
TYPEINIT1( XMLTextFrameContext_Impl, SvXMLImportContext );
+void XMLTextFrameContext_Impl::SetNameForFrameFromPropSet()
+{
+ // set name
+ UniReference < XMLTextImportHelper > xTextImportHelper =
GetImport().GetTextImport();
+ Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
+
+ if( xNamed.is() && xTextImportHelper.is() )
+ {
+ OUString sOrigName( xNamed->getName() );
+ if( !sOrigName.getLength() ||
+ (sName.getLength() && sOrigName != sName) )
+ {
+ OUString sOldName( sName );
+ sal_Int32 i = 0;
+ while( xTextImportHelper->HasFrameByName( sName ) )
+ {
+ sName = sOldName;
+ sName += OUString::valueOf( ++i );
+ }
+ xNamed->setName( sName );
+ if( sName != sOldName )
+ xTextImportHelper->GetRenameMap().Add(
XML_TEXT_RENAME_TYPE_FRAME,
+ sOldName, sName );
+ }
+ }
+}
+
void XMLTextFrameContext_Impl::Create( sal_Bool /*bHRefOrBase64*/ )
{
UniReference < XMLTextImportHelper > xTextImportHelper =
@@ -581,27 +612,13 @@ void XMLTextFrameContext_Impl::Create( s
Reference< XPropertySetInfo > xPropSetInfo =
xPropSet->getPropertySetInfo();
- // set name
- Reference < XNamed > xNamed( xPropSet, UNO_QUERY );
- if( xNamed.is() )
- {
- OUString sOrigName( xNamed->getName() );
- if( !sOrigName.getLength() ||
- (sName.getLength() && sOrigName != sName) )
- {
- OUString sOldName( sName );
- sal_Int32 i = 0;
- while( xTextImportHelper->HasFrameByName( sName ) )
- {
- sName = sOldName;
- sName += OUString::valueOf( ++i );
- }
- xNamed->setName( sName );
- if( sName != sOldName )
- xTextImportHelper->GetRenameMap().Add(
XML_TEXT_RENAME_TYPE_FRAME,
-
sOldName, sName );
- }
- }
+ // #123261# set name, but only if wanted, e.g. for MultiImageSupport, it
will be set after
+ // it is decided which image will be used. This is done e.g. to avoid
double stuff and effects
+ // for the target to avoid double names
+ if(mbSetNameForFrame)
+ {
+ SetNameForFrameFromPropSet();
+ }
// frame style
XMLPropStyleContext *pStyle = 0;
@@ -805,42 +822,44 @@ sal_Bool XMLTextFrameContext_Impl::Creat
}
XMLTextFrameContext_Impl::XMLTextFrameContext_Impl(
- SvXMLImport& rImport,
- sal_uInt16 nPrfx, const OUString& rLName,
- const Reference< XAttributeList > & rAttrList,
- TextContentAnchorType eATyp,
- sal_uInt16 nNewType,
- const Reference< XAttributeList > & rFrameAttrList )
-: SvXMLImportContext( rImport, nPrfx, rLName )
+ SvXMLImport& rImport,
+ sal_uInt16 nPrfx, const OUString& rLName,
+ const Reference< XAttributeList > & rAttrList,
+ TextContentAnchorType eATyp,
+ sal_uInt16 nNewType,
+ const Reference< XAttributeList > & rFrameAttrList,
+ bool bSetNameForFrame)
+: SvXMLImportContext( rImport, nPrfx, rLName )
, mbListContextPushed( false )
-, sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
-, sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
-, sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
-, sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
-, sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
-, sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
-, sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
-, sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
-, sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
-, sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
-, sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
-, sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
-, sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
-, sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
-, sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
-, sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
-, sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
+, sWidth(RTL_CONSTASCII_USTRINGPARAM("Width"))
+, sWidthType(RTL_CONSTASCII_USTRINGPARAM("WidthType"))
+, sRelativeWidth(RTL_CONSTASCII_USTRINGPARAM("RelativeWidth"))
+, sHeight(RTL_CONSTASCII_USTRINGPARAM("Height"))
+, sRelativeHeight(RTL_CONSTASCII_USTRINGPARAM("RelativeHeight"))
+, sSizeType(RTL_CONSTASCII_USTRINGPARAM("SizeType"))
+, sIsSyncWidthToHeight(RTL_CONSTASCII_USTRINGPARAM("IsSyncWidthToHeight"))
+, sIsSyncHeightToWidth(RTL_CONSTASCII_USTRINGPARAM("IsSyncHeightToWidth"))
+, sHoriOrient(RTL_CONSTASCII_USTRINGPARAM("HoriOrient"))
+, sHoriOrientPosition(RTL_CONSTASCII_USTRINGPARAM("HoriOrientPosition"))
+, sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient"))
+, sVertOrientPosition(RTL_CONSTASCII_USTRINGPARAM("VertOrientPosition"))
+, sChainNextName(RTL_CONSTASCII_USTRINGPARAM("ChainNextName"))
+, sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType"))
+, sAnchorPageNo(RTL_CONSTASCII_USTRINGPARAM("AnchorPageNo"))
+, sGraphicURL(RTL_CONSTASCII_USTRINGPARAM("GraphicURL"))
+, sGraphicFilter(RTL_CONSTASCII_USTRINGPARAM("GraphicFilter"))
// --> OD 2009-07-22 #i73249#
//, sAlternativeText(RTL_CONSTASCII_USTRINGPARAM("AlternativeText"))
, sTitle(RTL_CONSTASCII_USTRINGPARAM("Title"))
, sDescription(RTL_CONSTASCII_USTRINGPARAM("Description"))
// <--
-, sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
-, sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
-,
sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
-,
sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
-, nType( nNewType )
-, eAnchorType( eATyp )
+, sFrameStyleName(RTL_CONSTASCII_USTRINGPARAM("FrameStyleName"))
+, sGraphicRotation(RTL_CONSTASCII_USTRINGPARAM("GraphicRotation"))
+,
sTextBoxServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextFrame"))
+,
sGraphicServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.GraphicObject"))
+, nType( nNewType )
+, eAnchorType( eATyp )
+, mbSetNameForFrame(bSetNameForFrame)
{
nX = 0;
nY = 0;
@@ -1441,13 +1460,25 @@ void XMLTextFrameContext::EndElement()
{
/// solve if multiple image child contexts were imported
/// the winner is returned, if something has yet to be done with it
- /*const SvXMLImportContext* pWinner =*/ solveMultipleImages();
+ const SvXMLImportContext* pWinner = solveMultipleImages();
- SvXMLImportContext *pContext = &m_xImplContext;
- XMLTextFrameContext_Impl *pImpl = PTR_CAST( XMLTextFrameContext_Impl,
pContext );
- if( pImpl )
- {
- pImpl->CreateIfNotThere();
+ // #123261# see if the winner is a XMLTextFrameContext_Impl
+ const XMLTextFrameContext_Impl* pImplWinner = dynamic_cast< const
XMLTextFrameContext_Impl* >(pWinner);
+
+ if(pImplWinner)
+ {
+ // #123261# if yes, set name now, after the winner is identified
(setting at each
+ // candidate may run into problems due to colliding with efforts in
the target to
+ // avoid double names, so only set one name at one image and not at
each)
+ const_cast< XMLTextFrameContext_Impl*
>(pImplWinner)->SetNameForFrameFromPropSet();
+ }
+
+ SvXMLImportContext *pContext = &m_xImplContext;
+ XMLTextFrameContext_Impl *pImpl = dynamic_cast< XMLTextFrameContext_Impl*
>(pContext);
+
+ if( pImpl )
+ {
+ pImpl->CreateIfNotThere();
// --> OD 2009-07-22 #i73249#
// // alternative text
@@ -1552,32 +1583,41 @@ SvXMLImportContext *XMLTextFrameContext:
setSupportsMultipleContents(IsXMLToken(rLocalName,
XML_IMAGE));
}
- if( !pContext )
- {
-
- pContext = new
XMLTextFrameContext_Impl( GetImport(), p_nPrefix,
-
rLocalName, xAttrList,
-
m_eDefaultAnchorType,
-
nFrameType,
-
m_xAttrList );
- }
+ if( !pContext )
+ {
+ pContext = new XMLTextFrameContext_Impl(
+ GetImport(),
+ p_nPrefix,
+ rLocalName,
+ xAttrList,
+ m_eDefaultAnchorType,
+ nFrameType,
+ m_xAttrList,
+ !getSupportsMultipleContents());
+ }
- m_xImplContext = pContext;
+ m_xImplContext = pContext;
if(getSupportsMultipleContents() && XML_TEXT_FRAME_GRAPHIC ==
nFrameType)
{
addContent(*m_xImplContext);
}
- }
- }
- }
+ }
+ }
+ }
else if(getSupportsMultipleContents() && XML_NAMESPACE_DRAW == p_nPrefix
&& IsXMLToken(rLocalName, XML_IMAGE))
{
// read another image
pContext = new XMLTextFrameContext_Impl(
- GetImport(), p_nPrefix, rLocalName, xAttrList,
- m_eDefaultAnchorType, XML_TEXT_FRAME_GRAPHIC, m_xAttrList);
-
+ GetImport(),
+ p_nPrefix,
+ rLocalName,
+ xAttrList,
+ m_eDefaultAnchorType,
+ XML_TEXT_FRAME_GRAPHIC,
+ m_xAttrList,
+ false);
+
m_xImplContext = pContext;
addContent(*m_xImplContext);
}