Kaydet (Commit) bcbdb64a authored tarafından Miklos Vajna's avatar Miklos Vajna

writerfilter: remove redundant virtual keywords in the RTF import

Also use default member initializers where possible.

Change-Id: I535c467cb0d604863a47aafbe42dcf3498c8717c
Reviewed-on: https://gerrit.libreoffice.org/39155Reviewed-by: 's avatarMiklos Vajna <vmiklos@collabora.co.uk>
Tested-by: 's avatarJenkins <ci@libreoffice.org>
üst fbd21472
......@@ -29,10 +29,10 @@ public:
/// Pointer to this stream.
using Pointer_t = std::shared_ptr<RTFDocument>;
virtual ~RTFDocument() { }
virtual ~RTFDocument() = default;
/// Resolves this document to a stream handler.
virtual void resolve(Stream& rHandler) override = 0;
void resolve(Stream& rHandler) override = 0;
};
/// Interface to create an RTFDocument instance.
......
......@@ -2088,7 +2088,7 @@ RTFError RTFDocumentImpl::popState()
case Destination::SHAPEPROPERTYNAME:
if (&m_aStates.top().aDestinationText != m_aStates.top().pDestinationText)
break; // not for nested group
aState.aShape.aProperties.push_back(std::make_pair(m_aStates.top().pDestinationText->makeStringAndClear(), OUString()));
aState.aShape.aProperties.emplace_back(m_aStates.top().pDestinationText->makeStringAndClear(), OUString());
break;
case Destination::SHAPEPROPERTYVALUE:
if (aState.aShape.aProperties.size())
......@@ -3258,58 +3258,13 @@ void RTFDocumentImpl::resetFrame()
m_aStates.top().aFrame = RTFFrame(&m_aStates.top());
}
RTFColorTableEntry::RTFColorTableEntry()
: nRed(0),
nGreen(0),
nBlue(0)
{
}
RTFColorTableEntry::RTFColorTableEntry() = default;
RTFPicture::RTFPicture()
: nWidth(0),
nHeight(0),
nGoalWidth(0),
nGoalHeight(0),
nScaleX(100),
nScaleY(100),
nCropT(0),
nCropB(0),
nCropL(0),
nCropR(0),
eWMetafile(0),
eStyle(RTFBmpStyle::NONE)
{
}
RTFPicture::RTFPicture() = default;
RTFShape::RTFShape()
: nLeft(0),
nTop(0),
nRight(0),
nBottom(0),
nHoriOrientRelation(0),
nVertOrientRelation(0),
nHoriOrientRelationToken(0),
nVertOrientRelationToken(0),
nWrap(text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE),
bInBackground(false)
{
}
RTFShape::RTFShape() = default;
RTFDrawingObject::RTFDrawingObject()
: nLineColorR(0),
nLineColorG(0),
nLineColorB(0),
bHasLineColor(false),
nFillColorR(0),
nFillColorG(0),
nFillColorB(0),
bHasFillColor(false),
nDhgt(0),
nFLine(-1),
nPolyLineCount(0),
bHadShapeText(false)
{
}
RTFDrawingObject::RTFDrawingObject() = default;
RTFFrame::RTFFrame(RTFParserState* pParserState)
: m_pDocumentImpl(pParserState->m_pDocumentImpl),
......
......@@ -110,12 +110,12 @@ struct TableRowBuffer
writerfilter::Reference<Properties>::Pointer_t pFrameProperties;
writerfilter::Reference<Properties>::Pointer_t pRowProperties;
TableRowBuffer(RTFBuffer_t const& rBuffer,
::std::deque<RTFSprms> const& rSprms,
::std::deque<RTFSprms> const& rAttributes,
TableRowBuffer(RTFBuffer_t aBuffer,
std::deque<RTFSprms> aSprms,
std::deque<RTFSprms> aAttributes,
int const i_nCells)
: buffer(rBuffer)
, cellsSprms(rSprms), cellsAttributes(rAttributes)
: buffer(std::move(aBuffer))
, cellsSprms(std::move(aSprms)), cellsAttributes(std::move(aAttributes))
, nCells(i_nCells)
{}
};
......@@ -125,9 +125,9 @@ class RTFColorTableEntry
{
public:
RTFColorTableEntry();
sal_uInt8 nRed;
sal_uInt8 nGreen;
sal_uInt8 nBlue;
sal_uInt8 nRed = 0;
sal_uInt8 nGreen = 0;
sal_uInt8 nBlue = 0;
};
/// Stores the properties of a shape.
......@@ -137,18 +137,18 @@ public:
RTFShape();
std::vector< std::pair<OUString, OUString> > aProperties; ///< Properties of a single shape.
std::vector< std::pair<OUString, OUString> > aGroupProperties; ///< Properties applied on the groupshape.
sal_Int32 nLeft;
sal_Int32 nTop;
sal_Int32 nRight;
sal_Int32 nBottom;
sal_Int32 nLeft = 0;
sal_Int32 nTop = 0;
sal_Int32 nRight = 0;
sal_Int32 nBottom = 0;
boost::optional<sal_Int32> oZ; ///< Z-Order of the shape.
sal_Int16 nHoriOrientRelation; ///< Horizontal text::RelOrientation for drawinglayer shapes.
sal_Int16 nVertOrientRelation; ///< Vertical text::RelOrientation for drawinglayer shapes.
sal_uInt32 nHoriOrientRelationToken; ///< Horizontal dmapper token for Writer pictures.
sal_uInt32 nVertOrientRelationToken; ///< Vertical dmapper token for Writer pictures.
css::text::WrapTextMode nWrap;
sal_Int16 nHoriOrientRelation = 0; ///< Horizontal text::RelOrientation for drawinglayer shapes.
sal_Int16 nVertOrientRelation = 0; ///< Vertical text::RelOrientation for drawinglayer shapes.
sal_uInt32 nHoriOrientRelationToken = 0; ///< Horizontal dmapper token for Writer pictures.
sal_uInt32 nVertOrientRelationToken = 0; ///< Vertical dmapper token for Writer pictures.
css::text::WrapTextMode nWrap = css::text::WrapTextMode::WrapTextMode_MAKE_FIXED_SIZE;
/// If shape is below text (true) or text is below shape (false).
bool bInBackground;
bool bInBackground = false;
/// Wrap polygon, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
RTFSprms aWrapPolygonSprms;
/// Anchor attributes like wrap distance, written by RTFSdrImport::resolve(), read by RTFDocumentImpl::resolvePict().
......@@ -163,15 +163,19 @@ public:
css::uno::Reference<css::drawing::XShape> xShape;
css::uno::Reference<css::beans::XPropertySet> xPropertySet;
std::vector<css::beans::PropertyValue> aPendingProperties;
sal_uInt8 nLineColorR, nLineColorG, nLineColorB;
bool bHasLineColor;
sal_uInt8 nFillColorR, nFillColorG, nFillColorB;
bool bHasFillColor;
sal_Int32 nDhgt;
sal_Int32 nFLine;
sal_Int32 nPolyLineCount;
sal_uInt8 nLineColorR = 0;
sal_uInt8 nLineColorG = 0;
sal_uInt8 nLineColorB = 0;
bool bHasLineColor = false;
sal_uInt8 nFillColorR = 0;
sal_uInt8 nFillColorG = 0;
sal_uInt8 nFillColorB = 0;
bool bHasFillColor = false;
sal_Int32 nDhgt = 0;
sal_Int32 nFLine = -1;
sal_Int32 nPolyLineCount = 0;
std::vector<css::awt::Point> aPolyLinePoints;
bool bHadShapeText;
bool bHadShapeText = false;
};
/// Stores the properties of a picture.
......@@ -179,12 +183,18 @@ class RTFPicture
{
public:
RTFPicture();
sal_uInt16 nWidth, nHeight;
sal_uInt16 nGoalWidth, nGoalHeight;
sal_uInt16 nScaleX, nScaleY;
short nCropT, nCropB, nCropL, nCropR;
sal_uInt16 eWMetafile;
RTFBmpStyle eStyle;
sal_uInt16 nWidth = 0;
sal_uInt16 nHeight = 0;
sal_uInt16 nGoalWidth = 0;
sal_uInt16 nGoalHeight = 0;
sal_uInt16 nScaleX = 100;
sal_uInt16 nScaleY = 100;
short nCropT = 0;
short nCropB = 0;
short nCropL = 0;
short nCropR = 0;
sal_uInt16 eWMetafile = 0;
RTFBmpStyle eStyle = RTFBmpStyle::NONE;
};
/// Stores the properties of a frame
......@@ -383,28 +393,28 @@ public:
css::uno::Reference<css::frame::XFrame> const& xFrame,
css::uno::Reference<css::task::XStatusIndicator> const& xStatusIndicator,
const utl::MediaDescriptor& rMediaDescriptor);
virtual ~RTFDocumentImpl() override;
~RTFDocumentImpl() override;
// RTFDocument
virtual void resolve(Stream& rHandler) override;
void resolve(Stream& rHandler) override;
// RTFListener
virtual RTFError dispatchDestination(RTFKeyword nKeyword) override;
virtual RTFError dispatchFlag(RTFKeyword nKeyword) override;
virtual RTFError dispatchSymbol(RTFKeyword nKeyword) override;
virtual RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) override;
virtual RTFError dispatchValue(RTFKeyword nKeyword, int nParam) override;
virtual RTFError resolveChars(char ch) override;
virtual RTFError pushState() override;
virtual RTFError popState() override;
virtual Destination getDestination() override;
virtual void setDestination(Destination eDestination) override;
virtual RTFInternalState getInternalState() override;
virtual void setInternalState(RTFInternalState nInternalState) override;
virtual bool getSkipUnknown() override;
virtual void setSkipUnknown(bool bSkipUnknown) override;
virtual void finishSubstream() override;
virtual bool isSubstream() const override;
RTFError dispatchDestination(RTFKeyword nKeyword) override;
RTFError dispatchFlag(RTFKeyword nKeyword) override;
RTFError dispatchSymbol(RTFKeyword nKeyword) override;
RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) override;
RTFError dispatchValue(RTFKeyword nKeyword, int nParam) override;
RTFError resolveChars(char ch) override;
RTFError pushState() override;
RTFError popState() override;
Destination getDestination() override;
void setDestination(Destination eDestination) override;
RTFInternalState getInternalState() override;
void setInternalState(RTFInternalState nInternalState) override;
bool getSkipUnknown() override;
void setSkipUnknown(bool bSkipUnknown) override;
void finishSubstream() override;
bool isSubstream() const override;
Stream& Mapper()
{
......
......@@ -43,7 +43,7 @@ enum class RTFError
class RTFListener
{
public:
virtual ~RTFListener() { }
virtual ~RTFListener() = default;
// Dispatching of control words and characters.
virtual RTFError dispatchDestination(RTFKeyword nKeyword) = 0;
virtual RTFError dispatchFlag(RTFKeyword nKeyword) = 0;
......
......@@ -28,23 +28,23 @@ class RTFLookahead : public RTFListener
{
public:
RTFLookahead(SvStream& rStream, sal_uInt64 nGroupStart);
virtual ~RTFLookahead() override;
virtual RTFError dispatchDestination(RTFKeyword nKeyword) override;
virtual RTFError dispatchFlag(RTFKeyword nKeyword) override;
virtual RTFError dispatchSymbol(RTFKeyword nKeyword) override;
virtual RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) override;
virtual RTFError dispatchValue(RTFKeyword nKeyword, int nParam) override;
virtual RTFError resolveChars(char ch) override;
virtual RTFError pushState() override;
virtual RTFError popState() override;
virtual Destination getDestination() override;
virtual void setDestination(Destination eDestination) override;
virtual RTFInternalState getInternalState() override;
virtual void setInternalState(RTFInternalState nInternalState) override;
virtual bool getSkipUnknown() override;
virtual void setSkipUnknown(bool bSkipUnknown) override;
virtual void finishSubstream() override;
virtual bool isSubstream() const override;
~RTFLookahead() override;
RTFError dispatchDestination(RTFKeyword nKeyword) override;
RTFError dispatchFlag(RTFKeyword nKeyword) override;
RTFError dispatchSymbol(RTFKeyword nKeyword) override;
RTFError dispatchToggle(RTFKeyword nKeyword, bool bParam, int nParam) override;
RTFError dispatchValue(RTFKeyword nKeyword, int nParam) override;
RTFError resolveChars(char ch) override;
RTFError pushState() override;
RTFError popState() override;
Destination getDestination() override;
void setDestination(Destination eDestination) override;
RTFInternalState getInternalState() override;
void setInternalState(RTFInternalState nInternalState) override;
bool getSkipUnknown() override;
void setSkipUnknown(bool bSkipUnknown) override;
void finishSubstream() override;
bool isSubstream() const override;
bool hasTable()
{
return m_bHasTable;
......
......@@ -24,7 +24,7 @@ public:
RTFReferenceProperties(const RTFSprms& rAttributes, const RTFSprms& rSprms);
explicit RTFReferenceProperties(const RTFSprms& rAttributes);
virtual ~RTFReferenceProperties();
virtual void resolve(Properties& rHandler) override;
void resolve(Properties& rHandler) override;
RTFSprms& getAttributes()
{
return m_aAttributes;
......
......@@ -26,7 +26,7 @@ public:
using Entry_t = std::pair<int, writerfilter::Reference<Properties>::Pointer_t>;
explicit RTFReferenceTable(Entries_t aEntries);
virtual ~RTFReferenceTable();
virtual void resolve(Table& rHandler) override;
void resolve(Table& rHandler) override;
private:
Entries_t m_aEntries;
};
......
......@@ -268,7 +268,7 @@ void RTFSprms::ensureCopyBeforeWrite()
{
if (m_pSprms->m_nRefCount > 1)
{
boost::intrusive_ptr<RTFSprmsImpl> pClone(new RTFSprmsImpl());
boost::intrusive_ptr<RTFSprmsImpl> pClone(new RTFSprmsImpl);
for (auto& rSprm : *m_pSprms)
pClone->push_back(std::make_pair(rSprm.first, RTFValue::Pointer_t(rSprm.second->Clone())));
m_pSprms = pClone;
......@@ -276,7 +276,7 @@ void RTFSprms::ensureCopyBeforeWrite()
}
RTFSprms::RTFSprms()
: m_pSprms(new RTFSprmsImpl())
: m_pSprms(new RTFSprmsImpl)
{
}
......@@ -292,7 +292,7 @@ void RTFSprms::clear()
if (m_pSprms->m_nRefCount == 1)
return m_pSprms->clear();
else
m_pSprms.reset(new RTFSprmsImpl());
m_pSprms.reset(new RTFSprmsImpl);
}
} // namespace rtftok
......
......@@ -28,8 +28,7 @@ using RTFSprmsImplBase = std::vector< std::pair<Id, RTFValue::Pointer_t> >;
class RTFSprmsImpl : public RTFSprmsImplBase
{
public:
sal_Int32 m_nRefCount;
RTFSprmsImpl() : RTFSprmsImplBase(), m_nRefCount(0) {}
sal_Int32 m_nRefCount = 0;
};
inline void intrusive_ptr_add_ref(RTFSprmsImpl* p)
......@@ -102,13 +101,13 @@ class RTFSprm
{
public:
RTFSprm(Id nKeyword, RTFValue::Pointer_t& pValue);
virtual ~RTFSprm() {}
virtual sal_uInt32 getId() const override;
virtual Value::Pointer_t getValue() override;
virtual writerfilter::Reference<Properties>::Pointer_t getProps() override;
virtual ~RTFSprm() = default;
sal_uInt32 getId() const override;
Value::Pointer_t getValue() override;
writerfilter::Reference<Properties>::Pointer_t getProps() override;
#ifdef DEBUG_WRITERFILTER
virtual std::string getName() const override;
virtual std::string toString() const override;
std::string getName() const override;
std::string toString() const override;
#endif
private:
Id m_nKeyword;
......
......@@ -40,10 +40,8 @@ RTFValue::RTFValue(int nValue, OUString sValue,
}
RTFValue::RTFValue()
: m_nValue(0),
m_pAttributes(std::make_shared<RTFSprms>()),
: m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>())
{
......@@ -53,15 +51,13 @@ RTFValue::RTFValue(int nValue)
: m_nValue(nValue),
m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_bForceString(false),
m_pPicture(std::make_shared<RTFPicture>())
{
m_pShape.reset(new RTFShape());
}
RTFValue::RTFValue(OUString sValue, bool bForce)
: m_nValue(),
m_sValue(std::move(sValue)),
: m_sValue(std::move(sValue)),
m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_bForceString(bForce),
......@@ -71,73 +67,59 @@ RTFValue::RTFValue(OUString sValue, bool bForce)
}
RTFValue::RTFValue(RTFSprms rAttributes)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>(rAttributes)),
: m_pAttributes(std::make_shared<RTFSprms>(rAttributes)),
m_pSprms(std::make_shared<RTFSprms>()),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>())
{
}
RTFValue::RTFValue(RTFSprms rAttributes, RTFSprms rSprms)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>(rAttributes)),
: m_pAttributes(std::make_shared<RTFSprms>(rAttributes)),
m_pSprms(std::make_shared<RTFSprms>(rSprms)),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>())
{
}
RTFValue::RTFValue(uno::Reference<drawing::XShape> xShape)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>()),
: m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_xShape(std::move(xShape)),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>())
{
}
RTFValue::RTFValue(uno::Reference<io::XInputStream> xStream)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>()),
: m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_xStream(std::move(xStream)),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>())
{
}
RTFValue::RTFValue(uno::Reference<embed::XEmbeddedObject> xObject)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>()),
: m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_xObject(std::move(xObject)),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>())
{
}
RTFValue::RTFValue(const RTFShape& aShape)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>()),
: m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>(aShape)),
m_pPicture(std::make_shared<RTFPicture>())
{
}
RTFValue::RTFValue(const RTFPicture& rPicture)
: m_nValue(),
m_pAttributes(std::make_shared<RTFSprms>()),
: m_pAttributes(std::make_shared<RTFSprms>()),
m_pSprms(std::make_shared<RTFSprms>()),
m_bForceString(false),
m_pShape(std::make_shared<RTFShape>()),
m_pPicture(std::make_shared<RTFPicture>(rPicture))
{
......
......@@ -42,15 +42,15 @@ public:
explicit RTFValue(css::uno::Reference<css::embed::XEmbeddedObject> xObject);
explicit RTFValue(const RTFShape& aShape);
explicit RTFValue(const RTFPicture& rPicture);
virtual ~RTFValue() override;
~RTFValue() override;
void setString(const OUString& sValue);
virtual int getInt() const override;
virtual OUString getString() const override;
virtual css::uno::Any getAny() const override;
virtual writerfilter::Reference<Properties>::Pointer_t getProperties() override;
virtual writerfilter::Reference<BinaryObj>::Pointer_t getBinary() override;
int getInt() const override;
OUString getString() const override;
css::uno::Any getAny() const override;
writerfilter::Reference<Properties>::Pointer_t getProperties() override;
writerfilter::Reference<BinaryObj>::Pointer_t getBinary() override;
#ifdef DEBUG_WRITERFILTER
virtual std::string toString() const override;
std::string toString() const override;
#endif
RTFValue* Clone();
RTFValue* CloneWithSprms(RTFSprms const& rAttributes, RTFSprms const& rSprms);
......@@ -59,16 +59,16 @@ public:
RTFShape& getShape() const;
RTFPicture& getPicture() const;
bool equals(RTFValue& rOther);
private:
RTFValue& operator=(RTFValue const& rOther) = delete;
int m_nValue;
private:
int m_nValue = 0;
OUString m_sValue;
std::shared_ptr<RTFSprms> m_pAttributes;
std::shared_ptr<RTFSprms> m_pSprms;
css::uno::Reference<css::drawing::XShape> m_xShape;
css::uno::Reference<css::io::XInputStream> m_xStream;
css::uno::Reference<css::embed::XEmbeddedObject> m_xObject;
bool m_bForceString;
bool m_bForceString = false;
std::shared_ptr<RTFShape> m_pShape;
std::shared_ptr<RTFPicture> m_pPicture;
};
......
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