Kaydet (Commit) 22461ae3 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Michael Stahl

Convert SV_DECL_PTRARR_SORT_DEL(HTMLControls) to o3tl::sorted_vector

I had to move the HTMLControl struct to the header file to avoid
warnings about delete not being called.

Change-Id: I822afba210d34f5855ae052fb34e117a16578970
üst 637b9d4f
...@@ -90,31 +90,6 @@ const sal_uInt32 HTML_FRMOPTS_IMG_CONTROL_CSS1 = ...@@ -90,31 +90,6 @@ const sal_uInt32 HTML_FRMOPTS_IMG_CONTROL_CSS1 =
struct HTMLControl
{
// die Form, zu der das Control gehoert
uno::Reference< container::XIndexContainer > xFormComps;
sal_uLong nNdIdx; // der Node, in dem es verankert ist
xub_StrLen nCount; // wie viele Controls sind in dem Node
HTMLControl( const uno::Reference< container::XIndexContainer > & rForm,
sal_uInt32 nIdx );
~HTMLControl();
// operatoren fuer das Sort-Array
sal_Bool operator==( const HTMLControl& rCtrl )
{
return nNdIdx == rCtrl.nNdIdx;
}
sal_Bool operator<( const HTMLControl& rCtrl )
{
return nNdIdx < rCtrl.nNdIdx;
}
};
SV_IMPL_OP_PTRARR_SORT( HTMLControls, HTMLControl* )
void lcl_html_outEvents( SvStream& rStrm, void lcl_html_outEvents( SvStream& rStrm,
const uno::Reference< form::XFormComponent > rFormComp, const uno::Reference< form::XFormComponent > rFormComp,
sal_Bool bCfgStarBasic, sal_Bool bCfgStarBasic,
...@@ -261,11 +236,11 @@ sal_Bool SwHTMLWriter::HasControls() const ...@@ -261,11 +236,11 @@ sal_Bool SwHTMLWriter::HasControls() const
sal_uInt16 i; sal_uInt16 i;
// Skip all controls in front of the current paragraph // Skip all controls in front of the current paragraph
for( i = 0; i < aHTMLControls.Count() && for( i = 0; i < aHTMLControls.size() &&
aHTMLControls[i]->nNdIdx < nStartIdx; i++ ) aHTMLControls[i]->nNdIdx < nStartIdx; i++ )
; ;
return i < aHTMLControls.Count() && aHTMLControls[i]->nNdIdx == nStartIdx; return i < aHTMLControls.size() && aHTMLControls[i]->nNdIdx == nStartIdx;
} }
void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd ) void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd )
...@@ -291,7 +266,7 @@ void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd ) ...@@ -291,7 +266,7 @@ void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd )
// Ueberspringen von Controls vor dem interesanten Bereich // Ueberspringen von Controls vor dem interesanten Bereich
sal_uInt16 i; sal_uInt16 i;
for( i = 0; i < aHTMLControls.Count() && for( i = 0; i < aHTMLControls.size() &&
aHTMLControls[i]->nNdIdx < nStartIdx; i++ ) aHTMLControls[i]->nNdIdx < nStartIdx; i++ )
; ;
...@@ -299,7 +274,7 @@ void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd ) ...@@ -299,7 +274,7 @@ void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd )
{ {
// Check fuer einen einzelnen Node: da ist nur interessant, ob // Check fuer einen einzelnen Node: da ist nur interessant, ob
// es zu dem Node ein Control gibt und zu welcher Form es gehoert // es zu dem Node ein Control gibt und zu welcher Form es gehoert
if( i < aHTMLControls.Count() && if( i < aHTMLControls.size() &&
aHTMLControls[i]->nNdIdx == nStartIdx ) aHTMLControls[i]->nNdIdx == nStartIdx )
xNewFormComps = aHTMLControls[i]->xFormComps; xNewFormComps = aHTMLControls[i]->xFormComps;
} }
...@@ -314,7 +289,7 @@ void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd ) ...@@ -314,7 +289,7 @@ void SwHTMLWriter::OutForm( sal_Bool bTag_On, const SwStartNode *pStartNd )
const SwStartNode *pCurrentStNd = 0; // und der Start-Node eines Ctrls const SwStartNode *pCurrentStNd = 0; // und der Start-Node eines Ctrls
xub_StrLen nCurrentCtrls = 0; // und die in ihr gefundenen Controls xub_StrLen nCurrentCtrls = 0; // und die in ihr gefundenen Controls
sal_uInt32 nEndIdx = pStartNd->EndOfSectionIndex(); sal_uInt32 nEndIdx = pStartNd->EndOfSectionIndex();
for( ; i < aHTMLControls.Count() && for( ; i < aHTMLControls.size() &&
aHTMLControls[i]->nNdIdx <= nEndIdx; i++ ) aHTMLControls[i]->nNdIdx <= nEndIdx; i++ )
{ {
const SwStartNode *pCntrlStNd = const SwStartNode *pCntrlStNd =
...@@ -1393,12 +1368,13 @@ static void AddControl( HTMLControls& rControls, ...@@ -1393,12 +1368,13 @@ static void AddControl( HTMLControls& rControls,
{ {
uno::Reference< container::XIndexContainer > xFormComps( xForm, uno::UNO_QUERY ); uno::Reference< container::XIndexContainer > xFormComps( xForm, uno::UNO_QUERY );
HTMLControl *pHCntrl = new HTMLControl( xFormComps, nNodeIdx ); HTMLControl *pHCntrl = new HTMLControl( xFormComps, nNodeIdx );
if( !rControls.C40_PTR_INSERT( HTMLControl, pHCntrl ) ) HTMLControls::const_iterator it = rControls.find( pHCntrl );
if( it == rControls.end() )
rControls.insert( pHCntrl );
else
{ {
sal_uInt16 nPos = 0; if( (*it)->xFormComps==xFormComps )
if( rControls.Seek_Entry(pHCntrl,&nPos) && (*it)->nCount++;
rControls[nPos]->xFormComps==xFormComps )
rControls[nPos]->nCount++;
delete pHCntrl; delete pHCntrl;
} }
} }
...@@ -1465,5 +1441,4 @@ HTMLControl::HTMLControl( ...@@ -1465,5 +1441,4 @@ HTMLControl::HTMLControl(
HTMLControl::~HTMLControl() HTMLControl::~HTMLControl()
{} {}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -381,8 +381,7 @@ sal_uLong SwHTMLWriter::WriteStream() ...@@ -381,8 +381,7 @@ sal_uLong SwHTMLWriter::WriteStream()
pHTMLPosFlyFrms = 0; pHTMLPosFlyFrms = 0;
} }
if( aHTMLControls.Count() ) aHTMLControls.DeleteAndDestroyAll();
aHTMLControls.DeleteAndDestroy( sal_uInt16(0), aHTMLControls.Count() );
if( !aChrFmtInfos.empty() ) if( !aChrFmtInfos.empty() )
aChrFmtInfos.clear(); aChrFmtInfos.clear();
......
...@@ -35,9 +35,9 @@ ...@@ -35,9 +35,9 @@
#include <com/sun/star/container/XIndexContainer.hpp> #include <com/sun/star/container/XIndexContainer.hpp>
#include <com/sun/star/form/XForm.hpp> #include <com/sun/star/form/XForm.hpp>
#include <vcl/field.hxx> #include <vcl/field.hxx>
#include <svl/svstdarr.hxx>
#include <i18npool/lang.h> #include <i18npool/lang.h>
#include <tools/stream.hxx> #include <tools/stream.hxx>
#include <o3tl/sorted_vector.hxx>
#include "shellio.hxx" #include "shellio.hxx"
#include "wrt_fn.hxx" #include "wrt_fn.hxx"
...@@ -191,8 +191,35 @@ const sal_uInt32 HTML_FRMOPTS_GENIMG = ...@@ -191,8 +191,35 @@ const sal_uInt32 HTML_FRMOPTS_GENIMG =
#define CSS1_OUTMODE_SCRIPT ((sal_uInt16)(0x0007U << 11)) #define CSS1_OUTMODE_SCRIPT ((sal_uInt16)(0x0007U << 11))
// der HTML-Writer // der HTML-Writer
struct HTMLControl; struct HTMLControl
SV_DECL_PTRARR_SORT_DEL( HTMLControls, HTMLControl*, 1 ) {
// die Form, zu der das Control gehoert
::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > xFormComps;
sal_uLong nNdIdx; // der Node, in dem es verankert ist
xub_StrLen nCount; // wie viele Controls sind in dem Node
HTMLControl( const ::com::sun::star::uno::Reference< ::com::sun::star::container::XIndexContainer > & rForm,
sal_uInt32 nIdx );
~HTMLControl();
// operatoren fuer das Sort-Array
bool operator==( const HTMLControl& rCtrl ) const
{
return nNdIdx == rCtrl.nNdIdx;
}
bool operator<( const HTMLControl& rCtrl ) const
{
return nNdIdx < rCtrl.nNdIdx;
}
};
class HTMLControls : public o3tl::sorted_vector<HTMLControl*, o3tl::less_ptr_to<HTMLControl> > {
public:
// will free any items still in the vector
~HTMLControls() { DeleteAndDestroyAll(); }
};
typedef std::vector<SwFmtINetFmt*> INetFmts; typedef std::vector<SwFmtINetFmt*> INetFmts;
struct SwHTMLFmtInfo struct SwHTMLFmtInfo
......
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