Kaydet (Commit) a9ef9437 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in sdext

Change-Id: I0870d4b1e85465b07e3d9cdb05520fcb37dfc267
Reviewed-on: https://gerrit.libreoffice.org/50659Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 240e67e3
......@@ -77,7 +77,7 @@ namespace pdfi
: x( 0 ), y( 0 ), w( 0 ), h( 0 ), StyleId( -1 ), Parent( pParent )
{
if( pParent )
pParent->Children.push_back( this );
pParent->Children.emplace_back( this );
}
public:
......@@ -87,7 +87,7 @@ namespace pdfi
To be implemented by every tree node that needs to be
visitable.
*/
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& rParentIt ) = 0;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& rParentIt ) = 0;
/// Apply visitor to all children
void applyToChildren( ElementTreeVisitor& );
/// Union element geometry with given element
......@@ -100,18 +100,18 @@ namespace pdfi
/** el must be a valid dereferenceable iterator of el->Parent->Children
pNewParent must not be NULL
*/
static void setParent( std::list<Element*>::iterator const & el, Element* pNewParent );
static void setParent( std::list<std::unique_ptr<Element>>::iterator const & el, Element* pNewParent );
double x, y, w, h;
sal_Int32 StyleId;
Element* Parent;
std::list<Element*> Children;
std::list<std::unique_ptr<Element>> Children;
};
struct ListElement : public Element
{
ListElement() : Element( nullptr ) {}
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
struct HyperlinkElement : public Element
......@@ -121,7 +121,7 @@ namespace pdfi
HyperlinkElement( Element* pParent, const OUString& rURI )
: Element( pParent ), URI( rURI ) {}
public:
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
OUString URI;
};
......@@ -166,7 +166,7 @@ namespace pdfi
: DrawElement( pParent, nGCId ) {}
public:
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
struct TextElement : public GraphicalElement
......@@ -177,7 +177,7 @@ namespace pdfi
: GraphicalElement( pParent, nGCId ), FontId( nFontId ) {}
public:
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
OUStringBuffer Text;
sal_Int32 FontId;
......@@ -190,7 +190,7 @@ namespace pdfi
explicit ParagraphElement( Element* pParent ) : Element( pParent ), Type( Normal ), bRtl( false ) {}
public:
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& rParentIt ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& rParentIt ) override;
// returns true only if only a single line is contained
bool isSingleLined( PDFIProcessor const & rProc ) const;
......@@ -213,7 +213,7 @@ namespace pdfi
const basegfx::B2DPolyPolygon& rPolyPoly,
sal_Int8 nAction );
public:
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& rParentIt ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& rParentIt ) override;
void updateGeometry();
......@@ -233,7 +233,7 @@ namespace pdfi
: DrawElement( pParent, nGCId ), Image( nImage ) {}
public:
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
ImageId Image;
};
......@@ -249,11 +249,11 @@ namespace pdfi
{}
private:
// helper method for resolveHyperlinks
bool resolveHyperlink( const std::list<Element*>::iterator& link_it, std::list<Element*>& rElements );
bool resolveHyperlink( const std::list<std::unique_ptr<Element>>::iterator& link_it, std::list<std::unique_ptr<Element>>& rElements );
public:
virtual ~PageElement() override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& rParentIt ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& rParentIt ) override;
static void updateParagraphGeometry( Element* pEle );
void resolveHyperlinks();
......@@ -266,8 +266,8 @@ namespace pdfi
double BottomMargin;
double LeftMargin;
double RightMargin;
Element* HeaderElement;
Element* FooterElement;
std::unique_ptr<Element> HeaderElement;
std::unique_ptr<Element> FooterElement;
};
struct DocumentElement : public Element
......@@ -278,7 +278,7 @@ namespace pdfi
public:
virtual ~DocumentElement() override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< Element* >::const_iterator& ) override;
virtual void visitedBy( ElementTreeVisitor&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
// this class is the differentiator of document types: it will create
......
......@@ -43,14 +43,14 @@ namespace pdfi
*/
struct ElementTreeVisitor
{
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) = 0;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) = 0;
virtual ~ElementTreeVisitor() {}
};
typedef std::shared_ptr<ElementTreeVisitor> ElementTreeVisitorSharedPtr;
......
......@@ -44,14 +44,14 @@ namespace pdfi
m_rProcessor(rProcessor)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
class DrawXmlFinalizer : public ElementTreeVisitor
......@@ -67,14 +67,14 @@ namespace pdfi
m_rProcessor(rProcessor)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
class DrawXmlEmitter : public ElementTreeVisitor
......@@ -100,14 +100,14 @@ namespace pdfi
m_bWriteDrawDocument(eDocType==DRAW_DOC)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
}
......
......@@ -543,7 +543,7 @@ void PDFIProcessor::emit( XmlEmitter& rEmitter,
rVisitorFactory.createOptimizingVisitor(*this));
// FIXME: localization
startIndicator( " " );
m_pDocument->visitedBy( *optimizingVisitor, std::list<Element*>::const_iterator());
m_pDocument->visitedBy( *optimizingVisitor, std::list<std::unique_ptr<Element>>::const_iterator());
#if OSL_DEBUG_LEVEL > 0
m_pDocument->emitStructure( 0 );
......@@ -555,7 +555,7 @@ void PDFIProcessor::emit( XmlEmitter& rEmitter,
rVisitorFactory.createStyleCollectingVisitor(aStyles,*this));
// FIXME: localization
m_pDocument->visitedBy( *finalizingVisitor, std::list<Element*>::const_iterator() );
m_pDocument->visitedBy( *finalizingVisitor, std::list<std::unique_ptr<Element>>::const_iterator() );
EmitContext aContext( rEmitter, aStyles, m_aImages, *this, m_xStatusIndicator, m_xContext );
ElementTreeVisitorSharedPtr aEmittingVisitor(
......@@ -589,7 +589,7 @@ void PDFIProcessor::emit( XmlEmitter& rEmitter,
// emit style list
aStyles.emit( aContext, *aEmittingVisitor );
m_pDocument->visitedBy( *aEmittingVisitor, std::list<Element*>::const_iterator() );
m_pDocument->visitedBy( *aEmittingVisitor, std::list<std::unique_ptr<Element>>::const_iterator() );
aContext.rEmitter.endTag( "office:document" );
endIndicator();
}
......@@ -625,7 +625,7 @@ void PDFIProcessor::endIndicator()
m_xStatusIndicator->end();
}
static bool lr_tb_sort( Element* pLeft, Element* pRight )
static bool lr_tb_sort( std::unique_ptr<Element> const & pLeft, std::unique_ptr<Element> const & pRight )
{
// Ensure irreflexivity (which could be compromised if h or w is negative):
if (pLeft == pRight)
......@@ -637,9 +637,9 @@ static bool lr_tb_sort( Element* pLeft, Element* pRight )
// of the same order as font height whereas the real paint area
// of text is usually smaller
double fudge_factor_left = 0.0, fudge_factor_right = 0.0;
if( dynamic_cast< TextElement* >(pLeft) )
if( dynamic_cast< TextElement* >(pLeft.get()) )
fudge_factor_left = 0.1;
if (dynamic_cast< TextElement* >(pRight))
if (dynamic_cast< TextElement* >(pRight.get()))
fudge_factor_right = 0.1;
// Allow negative height
......
......@@ -201,7 +201,7 @@ void StyleContainer::impl_emitStyle( sal_Int32 nStyleId,
rContext.rEmitter.write( rStyle.Contents );
if( rStyle.ContainedElement )
rStyle.ContainedElement->visitedBy( rContainedElemVisitor,
std::list<Element*>::iterator() );
std::list<std::unique_ptr<Element>>::iterator() );
rContext.rEmitter.endTag( rStyle.Name.getStr() );
}
}
......
......@@ -38,14 +38,14 @@ namespace pdfi
m_rProcessor(rProcessor)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
class WriterXmlFinalizer : public ElementTreeVisitor
......@@ -65,14 +65,14 @@ namespace pdfi
m_rProcessor(rProcessor)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
class WriterXmlEmitter : public ElementTreeVisitor
......@@ -88,14 +88,14 @@ namespace pdfi
m_rEmitContext(rEmitContext)
{}
virtual void visit( HyperlinkElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< Element* >::const_iterator& ) override;
virtual void visit( HyperlinkElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( TextElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ParagraphElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( FrameElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PolyPolyElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( ImageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( PageElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
virtual void visit( DocumentElement&, const std::list< std::unique_ptr<Element> >::const_iterator& ) override;
};
}
......
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