Kaydet (Commit) 642088c5 authored tarafından Bjoern Michaelsen's avatar Bjoern Michaelsen

make CreateNextObject a member

Change-Id: I1bd9668a2567390ceceb1742483a9fdabc025db7
üst 540027c3
...@@ -1599,73 +1599,23 @@ struct SwXParaFrameEnumerationImpl SAL_FINAL : public SwXParaFrameEnumeration ...@@ -1599,73 +1599,23 @@ struct SwXParaFrameEnumerationImpl SAL_FINAL : public SwXParaFrameEnumeration
{ {
if(!m_pUnoCursor) if(!m_pUnoCursor)
{ {
m_Frames.clear(); m_vFrames.clear();
m_xNextObject = nullptr; m_xNextObject = nullptr;
} }
else else
{ {
// removing orphaned SwDepends // removing orphaned SwDepends
const auto iter = std::remove_if(m_Frames.begin(), m_Frames.end(), const auto iter = std::remove_if(m_vFrames.begin(), m_vFrames.end(),
[] (std::shared_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); }); [] (std::shared_ptr<sw::FrameClient>& rEntry) -> bool { return !rEntry->GetRegisteredIn(); });
m_Frames.erase(iter, m_Frames.end()); m_vFrames.erase(iter, m_vFrames.end());
} }
} }
// created by hasMoreElements bool CreateNextObject();
uno::Reference< text::XTextContent > m_xNextObject; uno::Reference< text::XTextContent > m_xNextObject;
FrameClientList_t m_Frames; FrameClientList_t m_vFrames;
::sw::UnoCursorPointer m_pUnoCursor; ::sw::UnoCursorPointer m_pUnoCursor;
}; };
static bool
lcl_CreateNextObject(SwUnoCrsr& i_rUnoCrsr,
uno::Reference<text::XTextContent> & o_rNextObject,
FrameClientList_t & i_rFrames)
{
if (!i_rFrames.size())
return false;
SwFrameFormat *const pFormat = static_cast<SwFrameFormat*>(
i_rFrames.front()->GetRegisteredIn());
i_rFrames.pop_front();
// the format should be valid here, otherwise the client
// would have been removed in ::Modify
// check for a shape first
SwDrawContact* const pContact = SwIterator<SwDrawContact,SwFormat>( *pFormat ).First();
if (pContact)
{
SdrObject * const pSdr = pContact->GetMaster();
if (pSdr)
{
o_rNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY);
}
}
else
{
const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
OSL_ENSURE(pIdx, "where is the index?");
SwNode const*const pNd =
i_rUnoCrsr.GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
if (!pNd->IsNoTextNode())
{
o_rNextObject.set(SwXTextFrame::CreateXTextFrame(
*pFormat->GetDoc(), pFormat));
}
else if (pNd->IsGrfNode())
{
o_rNextObject.set(SwXTextGraphicObject::CreateXTextGraphicObject(
*pFormat->GetDoc(), pFormat));
}
else
{
assert(pNd->IsOLENode());
o_rNextObject.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
*pFormat->GetDoc(), pFormat));
}
}
return o_rNextObject.is();
}
// Search for a FLYCNT text attribute at the cursor point and fill the frame // Search for a FLYCNT text attribute at the cursor point and fill the frame
// into the array // into the array
...@@ -1704,12 +1654,12 @@ SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl( ...@@ -1704,12 +1654,12 @@ SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl(
::CollectFrameAtNode(rPaM.GetPoint()->nNode, ::CollectFrameAtNode(rPaM.GetPoint()->nNode,
frames, false); frames, false);
::std::transform(frames.begin(), frames.end(), ::std::transform(frames.begin(), frames.end(),
::std::back_inserter(m_Frames), ::std::back_inserter(m_vFrames),
::boost::bind(&FrameClientSortListEntry::pFrameClient, _1)); ::boost::bind(&FrameClientSortListEntry::pFrameClient, _1));
} }
else if (pFormat) else if (pFormat)
{ {
m_Frames.push_back(std::shared_ptr<sw::FrameClient>(new sw::FrameClient(pFormat))); m_vFrames.push_back(std::shared_ptr<sw::FrameClient>(new sw::FrameClient(pFormat)));
} }
else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) || else if ((PARAFRAME_PORTION_CHAR == eParaFrameMode) ||
(PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode)) (PARAFRAME_PORTION_TEXTRANGE == eParaFrameMode))
...@@ -1723,14 +1673,61 @@ SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl( ...@@ -1723,14 +1673,61 @@ SwXParaFrameEnumerationImpl::SwXParaFrameEnumerationImpl(
{ {
SwFrameFormat *const pFrameFormat = const_cast<SwFrameFormat*>(&((*aIter)->GetFormat())); SwFrameFormat *const pFrameFormat = const_cast<SwFrameFormat*>(&((*aIter)->GetFormat()));
m_Frames.push_back(std::shared_ptr<sw::FrameClient>(new sw::FrameClient(pFrameFormat))); m_vFrames.push_back(std::shared_ptr<sw::FrameClient>(new sw::FrameClient(pFrameFormat)));
} }
} }
lcl_FillFrame(*GetCursor(), m_Frames); lcl_FillFrame(*GetCursor(), m_vFrames);
} }
} }
bool SwXParaFrameEnumerationImpl::CreateNextObject()
{
if (!m_vFrames.size())
return false;
SwFrameFormat* const pFormat = static_cast<SwFrameFormat*>(const_cast<SwModify*>(
m_vFrames.front()->GetRegisteredIn()));
m_vFrames.pop_front();
// the format should be valid here, otherwise the client
// would have been removed by PurgeFrameClients
// check for a shape first
SwDrawContact* const pContact = SwIterator<SwDrawContact,SwFormat>( *pFormat ).First();
if (pContact)
{
SdrObject * const pSdr = pContact->GetMaster();
if (pSdr)
{
m_xNextObject.set(pSdr->getUnoShape(), uno::UNO_QUERY);
}
}
else
{
const SwNodeIndex* pIdx = pFormat->GetContent().GetContentIdx();
OSL_ENSURE(pIdx, "where is the index?");
SwNode const*const pNd =
m_pUnoCursor->GetDoc()->GetNodes()[ pIdx->GetIndex() + 1 ];
if (!pNd->IsNoTextNode())
{
m_xNextObject.set(SwXTextFrame::CreateXTextFrame(
*pFormat->GetDoc(), pFormat));
}
else if (pNd->IsGrfNode())
{
m_xNextObject.set(SwXTextGraphicObject::CreateXTextGraphicObject(
*pFormat->GetDoc(), pFormat));
}
else
{
assert(pNd->IsOLENode());
m_xNextObject.set(SwXTextEmbeddedObject::CreateXTextEmbeddedObject(
*pFormat->GetDoc(), pFormat));
}
}
return m_xNextObject.is();
}
sal_Bool SAL_CALL sal_Bool SAL_CALL
SwXParaFrameEnumerationImpl::hasMoreElements() throw (uno::RuntimeException, std::exception) SwXParaFrameEnumerationImpl::hasMoreElements() throw (uno::RuntimeException, std::exception)
{ {
...@@ -1738,8 +1735,7 @@ SwXParaFrameEnumerationImpl::hasMoreElements() throw (uno::RuntimeException, std ...@@ -1738,8 +1735,7 @@ SwXParaFrameEnumerationImpl::hasMoreElements() throw (uno::RuntimeException, std
if (!GetCursor()) if (!GetCursor())
throw uno::RuntimeException(); throw uno::RuntimeException();
PurgeFrameClients(); PurgeFrameClients();
return m_xNextObject.is() || return m_xNextObject.is() || CreateNextObject();
lcl_CreateNextObject(*GetCursor(), m_xNextObject, m_Frames);
} }
uno::Any SAL_CALL SwXParaFrameEnumerationImpl::nextElement() uno::Any SAL_CALL SwXParaFrameEnumerationImpl::nextElement()
...@@ -1750,11 +1746,8 @@ throw (container::NoSuchElementException, ...@@ -1750,11 +1746,8 @@ throw (container::NoSuchElementException,
if (!GetCursor()) if (!GetCursor())
throw uno::RuntimeException(); throw uno::RuntimeException();
PurgeFrameClients(); PurgeFrameClients();
if (!m_xNextObject.is() && m_Frames.size()) if (!m_xNextObject.is() && m_vFrames.size())
{ CreateNextObject();
lcl_CreateNextObject(*GetCursor(),
m_xNextObject, m_Frames);
}
if (!m_xNextObject.is()) if (!m_xNextObject.is())
throw container::NoSuchElementException(); throw container::NoSuchElementException();
uno::Any aRet; uno::Any aRet;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment