new loplugin: useuniqueptr: svgio

Change-Id: I645ac954ac519fe713f4347cdf69780b0f8070e4
Reviewed-on: https://gerrit.libreoffice.org/33252
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Tested-by: Noel Grandin <noel.grandin@collabora.co.uk>
This commit is contained in:
Noel Grandin 2017-01-18 09:48:47 +02:00
parent 9767537e22
commit 2da34e265d
30 changed files with 67 additions and 64 deletions

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -34,7 +35,7 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
public:
SvgANode(
@ -47,8 +48,8 @@ namespace svgio
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// transform content
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -37,7 +38,7 @@ namespace svgio
SvgNumber maCx;
SvgNumber maCy;
SvgNumber maR;
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
public:
SvgCircleNode(
@ -59,8 +60,8 @@ namespace svgio
const SvgNumber& getR() const { return maR; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -34,7 +35,7 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
SvgUnits maClipPathUnits;
public:
@ -57,8 +58,8 @@ namespace svgio
void setClipPathUnits(const SvgUnits aClipPathUnits) { maClipPathUnits = aClipPathUnits; }
/// transform content
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -38,7 +39,7 @@ namespace svgio
SvgNumber maCy;
SvgNumber maRx;
SvgNumber maRy;
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
public:
SvgEllipseNode(
@ -63,8 +64,8 @@ namespace svgio
const SvgNumber& getRy() const { return maRy; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -34,7 +35,7 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
public:
SvgGNode(
@ -48,8 +49,8 @@ namespace svgio
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// transform content
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -23,6 +23,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <drawinglayer/primitive2d/svggradientprimitive2d.hxx>
#include <memory>
namespace svgio
{
@ -50,7 +51,7 @@ namespace svgio
/// variable scan values, dependent of given XAttributeList
SvgUnits maGradientUnits;
drawinglayer::primitive2d::SpreadMethod maSpreadMethod;
basegfx::B2DHomMatrix* mpaGradientTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaGradientTransform;
/// link to another gradient used as style. If maXLink
/// is set, the node can be fetched on demand by using

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -35,7 +36,8 @@ namespace svgio
/// variable scan values, dependent of given XAttributeList
SvgAspectRatio maSvgAspectRatio;
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix>
mpaTransform;
SvgNumber maX;
SvgNumber maY;
SvgNumber maWidth;
@ -58,8 +60,8 @@ namespace svgio
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
/// x content, set if found in current context
const SvgNumber& getX() const { return maX; }

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -38,7 +39,7 @@ namespace svgio
SvgNumber maY1;
SvgNumber maX2;
SvgNumber maY2;
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
public:
SvgLineNode(
@ -63,8 +64,8 @@ namespace svgio
const SvgNumber& getY2() const { return maY2; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -44,7 +45,8 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DRange* mpViewBox;
std::unique_ptr<basegfx::B2DRange>
mpViewBox;
SvgAspectRatio maSvgAspectRatio;
SvgNumber maRefX;
SvgNumber maRefY;
@ -71,8 +73,8 @@ namespace svgio
virtual const basegfx::B2DRange getCurrentViewPort() const override;
/// viewBox content
const basegfx::B2DRange* getViewBox() const { return mpViewBox; }
void setViewBox(const basegfx::B2DRange* pViewBox) { if(mpViewBox) delete mpViewBox; mpViewBox = nullptr; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
const basegfx::B2DRange* getViewBox() const { return mpViewBox.get(); }
void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset( new basegfx::B2DRange(*pViewBox) ); }
/// SvgAspectRatio content
const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -38,7 +39,8 @@ namespace svgio
SvgNumber maY;
SvgNumber maWidth;
SvgNumber maHeight;
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix>
mpaTransform;
SvgUnits maMaskUnits;
SvgUnits maMaskContentUnits;
@ -70,8 +72,8 @@ namespace svgio
const SvgNumber& getHeight() const { return maHeight; }
/// transform content
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
/// MaskUnits content
void setMaskUnits(const SvgUnits aMaskUnits) { maMaskUnits = aMaskUnits; }

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -40,7 +41,7 @@ namespace svgio
SvgNumber maHeight;
SvgNumber maRx;
SvgNumber maRy;
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix> mpaTransform;
public:
SvgRectNode(
@ -71,8 +72,8 @@ namespace svgio
const SvgNumber& getRy() const { return maRy; }
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -21,6 +21,7 @@
#define INCLUDED_SVGIO_INC_SVGSVGNODE_HXX
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -33,7 +34,8 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DRange* mpViewBox;
std::unique_ptr<basegfx::B2DRange>
mpViewBox;
SvgAspectRatio maSvgAspectRatio;
SvgNumber maX;
SvgNumber maY;
@ -70,8 +72,8 @@ namespace svgio
virtual const basegfx::B2DRange getCurrentViewPort() const override;
/// viewBox content
const basegfx::B2DRange* getViewBox() const { return mpViewBox; }
void setViewBox(const basegfx::B2DRange* pViewBox) { if(mpViewBox) delete mpViewBox; mpViewBox = nullptr; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
const basegfx::B2DRange* getViewBox() const { return mpViewBox.get(); }
void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset( new basegfx::B2DRange(*pViewBox) ); }
/// SvgAspectRatio content
const SvgAspectRatio& getSvgAspectRatio() const { return maSvgAspectRatio; }

View file

@ -21,6 +21,7 @@
#define INCLUDED_SVGIO_INC_SVGSYMBOLNODE_HXX
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -33,7 +34,8 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DRange* mpViewBox;
std::unique_ptr<basegfx::B2DRange>
mpViewBox;
SvgAspectRatio maSvgAspectRatio;
public:
@ -46,7 +48,7 @@ namespace svgio
virtual void parseAttribute(const OUString& rTokenName, SVGToken aSVGToken, const OUString& aContent) override;
/// viewBox content
void setViewBox(const basegfx::B2DRange* pViewBox) { if(mpViewBox) delete mpViewBox; mpViewBox = nullptr; if(pViewBox) mpViewBox = new basegfx::B2DRange(*pViewBox); }
void setViewBox(const basegfx::B2DRange* pViewBox) { mpViewBox.reset(); if(pViewBox) mpViewBox.reset( new basegfx::B2DRange(*pViewBox) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -23,6 +23,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <svgcharacternode.hxx>
#include <memory>
namespace svgio
{
@ -35,7 +36,8 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix>
mpaTransform;
SvgTextPositions maSvgTextPositions;
/// local helpers
@ -61,8 +63,8 @@ namespace svgio
virtual double getCurrentFontSize() const override;
/// transform content, set if found in current context
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
};
} // end of namespace svgreader
} // end of namespace svgio

View file

@ -22,6 +22,7 @@
#include <svgnode.hxx>
#include <svgstyleattributes.hxx>
#include <memory>
namespace svgio
{
@ -34,7 +35,8 @@ namespace svgio
SvgStyleAttributes maSvgStyleAttributes;
/// variable scan values, dependent of given XAttributeList
basegfx::B2DHomMatrix* mpaTransform;
std::unique_ptr<basegfx::B2DHomMatrix>
mpaTransform;
SvgNumber maX;
SvgNumber maY;
SvgNumber maWidth;
@ -55,8 +57,8 @@ namespace svgio
virtual void decomposeSvgNode(drawinglayer::primitive2d::Primitive2DContainer& rTarget, bool bReferenced) const override;
/// transform content
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform; }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { if(mpaTransform) delete mpaTransform; mpaTransform = nullptr; if(pMatrix) mpaTransform = new basegfx::B2DHomMatrix(*pMatrix); }
const basegfx::B2DHomMatrix* getTransform() const { return mpaTransform.get(); }
void setTransform(const basegfx::B2DHomMatrix* pMatrix) { mpaTransform.reset(); if(pMatrix) mpaTransform.reset( new basegfx::B2DHomMatrix(*pMatrix) ); }
/// x content
const SvgNumber& getX() const { return maX; }

View file

@ -36,7 +36,6 @@ namespace svgio
SvgANode::~SvgANode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgANode::getSvgStyleAttributes() const

View file

@ -39,7 +39,6 @@ namespace svgio
SvgCircleNode::~SvgCircleNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgCircleNode::getSvgStyleAttributes() const

View file

@ -42,7 +42,6 @@ namespace svgio
SvgClipPathNode::~SvgClipPathNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgClipPathNode::getSvgStyleAttributes() const

View file

@ -40,7 +40,6 @@ namespace svgio
SvgEllipseNode::~SvgEllipseNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgEllipseNode::getSvgStyleAttributes() const

View file

@ -38,7 +38,6 @@ namespace svgio
SvgGNode::~SvgGNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgGNode::getSvgStyleAttributes() const

View file

@ -59,7 +59,6 @@ namespace svgio
SvgGradientNode::~SvgGradientNode()
{
delete mpaGradientTransform;
// do NOT delete mpXLink, it's only referenced, not owned
}
@ -472,7 +471,7 @@ namespace svgio
{
if(mpaGradientTransform)
{
return mpaGradientTransform;
return mpaGradientTransform.get();
}
const_cast< SvgGradientNode* >(this)->tryToFindLink();
@ -487,15 +486,11 @@ namespace svgio
void SvgGradientNode::setGradientTransform(const basegfx::B2DHomMatrix* pMatrix)
{
if(mpaGradientTransform)
{
delete mpaGradientTransform;
mpaGradientTransform = nullptr;
}
mpaGradientTransform.reset();
if(pMatrix)
{
mpaGradientTransform = new basegfx::B2DHomMatrix(*pMatrix);
mpaGradientTransform.reset(new basegfx::B2DHomMatrix(*pMatrix) );
}
}

View file

@ -57,7 +57,6 @@ namespace svgio
SvgImageNode::~SvgImageNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgImageNode::getSvgStyleAttributes() const

View file

@ -40,7 +40,6 @@ namespace svgio
SvgLineNode::~SvgLineNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgLineNode::getSvgStyleAttributes() const

View file

@ -43,7 +43,6 @@ namespace svgio
SvgMarkerNode::~SvgMarkerNode()
{
delete mpViewBox;
}
const SvgStyleAttributes* SvgMarkerNode::getSvgStyleAttributes() const

View file

@ -48,7 +48,6 @@ namespace svgio
SvgMaskNode::~SvgMaskNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgMaskNode::getSvgStyleAttributes() const

View file

@ -42,7 +42,6 @@ namespace svgio
SvgRectNode::~SvgRectNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgRectNode::getSvgStyleAttributes() const

View file

@ -106,7 +106,6 @@ namespace svgio
SvgSvgNode::~SvgSvgNode()
{
delete mpViewBox;
}
const SvgStyleAttributes* SvgSvgNode::getSvgStyleAttributes() const

View file

@ -37,7 +37,6 @@ namespace svgio
SvgSymbolNode::~SvgSymbolNode()
{
delete mpViewBox;
}
const SvgStyleAttributes* SvgSymbolNode::getSvgStyleAttributes() const

View file

@ -42,7 +42,6 @@ namespace svgio
SvgTextNode::~SvgTextNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgTextNode::getSvgStyleAttributes() const

View file

@ -41,7 +41,6 @@ namespace svgio
SvgUseNode::~SvgUseNode()
{
delete mpaTransform;
}
const SvgStyleAttributes* SvgUseNode::getSvgStyleAttributes() const