summaryrefslogtreecommitdiff
path: root/xmloff/source/core
diff options
context:
space:
mode:
authorArmin Le Grand <alg@apache.org>2012-11-21 09:46:38 +0000
committerArmin Le Grand <alg@apache.org>2012-11-21 09:46:38 +0000
commit202a345c32488dfc0ca6640f80dc2392a62911bc (patch)
tree39eb0e037b24d6c280b8e70765824349168cab22 /xmloff/source/core
parent4ae2ee84957b49f9b691341b8d9e93f920903d3c (diff)
#121379# When loading MultiImage, avoid registering xShape with ID until the winner is decided to not have multiple shapes registering with the same ID
Notes
Notes: prefer: 450cd772aa734cfcb989c8cedd3c0a454db74a34
Diffstat (limited to 'xmloff/source/core')
-rw-r--r--xmloff/source/core/xmlmultiimagehelper.cxx65
1 files changed, 39 insertions, 26 deletions
diff --git a/xmloff/source/core/xmlmultiimagehelper.cxx b/xmloff/source/core/xmlmultiimagehelper.cxx
index 9047ac9d125c..9accd4984575 100644
--- a/xmloff/source/core/xmlmultiimagehelper.cxx
+++ b/xmloff/source/core/xmlmultiimagehelper.cxx
@@ -94,44 +94,57 @@ multiImageImportHelper::~multiImageImportHelper()
}
}
-void multiImageImportHelper::solveMultipleImages()
+const SvXMLImportContext* multiImageImportHelper::solveMultipleImages()
{
- if(maImplContextVector.size() > 1)
- {
- // multiple child contexts were imported, decide which is the most valuable one
- // and remove the rest
- sal_uInt32 nIndexOfPreferred(maImplContextVector.size());
- sal_uInt32 nBestQuality(0), a(0);
+ const SvXMLImportContext* pRetval = 0;
- for(a = 0; a < maImplContextVector.size(); a++)
+ if(maImplContextVector.size())
+ {
+ if(maImplContextVector.size() > 1)
{
- const rtl::OUString aStreamURL(getGraphicURLFromImportContext(**maImplContextVector[a]));
- const sal_uInt32 nNewQuality(getQualityIndex(aStreamURL));
+ // multiple child contexts were imported, decide which is the most valuable one
+ // and remove the rest
+ sal_uInt32 nIndexOfPreferred(maImplContextVector.size());
+ sal_uInt32 nBestQuality(0), a(0);
- if(nNewQuality > nBestQuality)
+ for(a = 0; a < maImplContextVector.size(); a++)
{
- nBestQuality = nNewQuality;
- nIndexOfPreferred = a;
+ const rtl::OUString aStreamURL(getGraphicURLFromImportContext(**maImplContextVector[a]));
+ const sal_uInt32 nNewQuality(getQualityIndex(aStreamURL));
+
+ if(nNewQuality > nBestQuality)
+ {
+ nBestQuality = nNewQuality;
+ nIndexOfPreferred = a;
+ }
}
- }
- // correct if needed, default is to use the last entry
- if(nIndexOfPreferred >= maImplContextVector.size())
- {
- nIndexOfPreferred = maImplContextVector.size() - 1;
- }
+ // correct if needed, default is to use the last entry
+ if(nIndexOfPreferred >= maImplContextVector.size())
+ {
+ nIndexOfPreferred = maImplContextVector.size() - 1;
+ }
- // Take out the most valuable one
- const std::vector< SvXMLImportContextRef* >::iterator aRemove(maImplContextVector.begin() + nIndexOfPreferred);
- delete *aRemove;
- maImplContextVector.erase(aRemove);
+ // get the winner
+ pRetval = *maImplContextVector[nIndexOfPreferred];
- // remove the rest from parent
- for(a = 0; a < maImplContextVector.size(); a++)
+ // remove the rest from parent
+ for(a = 0; a < maImplContextVector.size(); a++)
+ {
+ if(a != nIndexOfPreferred)
+ {
+ removeGraphicFromImportContext(**maImplContextVector[a]);
+ }
+ }
+ }
+ else
{
- removeGraphicFromImportContext(**maImplContextVector[a]);
+ // only one, winner is implicit
+ pRetval = *maImplContextVector[0];
}
}
+
+ return pRetval;
}
void multiImageImportHelper::addContent(const SvXMLImportContext& rSvXMLImportContext)