Kaydet (Commit) db39c653 authored tarafından Noel Grandin's avatar Noel Grandin Kaydeden (comit) Noel Grandin

loplugin:singlevalfields in drawinglayer

Change-Id: I19f50b0afa624391bd0d8ada7afca822298e10cc
Reviewed-on: https://gerrit.libreoffice.org/26655Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noelgrandin@gmail.com>
üst 78ca0ce5
...@@ -66,48 +66,37 @@ namespace drawinglayer ...@@ -66,48 +66,37 @@ namespace drawinglayer
// create a mapping from content to object. // create a mapping from content to object.
basegfx::B2DHomMatrix aPageTrans; basegfx::B2DHomMatrix aPageTrans;
if(getKeepAspectRatio()) // #i101075# when keeping the aspect ratio is wanted, it is necessary to calculate
// an equidistant scaling in X and Y and a corresponding translation to
// center the output. Calculate needed scale factors
const double fScaleX(aScale.getX() / getContentWidth());
const double fScaleY(aScale.getY() / getContentHeight());
// to keep the aspect, use the smaller scale and adapt missing size by translation
if(fScaleX < fScaleY)
{ {
// #i101075# when keeping the aspect ratio is wanted, it is necessary to calculate // height needs to be adapted
// an equidistant scaling in X and Y and a corresponding translation to const double fNeededHeight(aScale.getY() / fScaleX);
// center the output. Calculate needed scale factors const double fSpaceToAdd(fNeededHeight - getContentHeight());
const double fScaleX(aScale.getX() / getContentWidth());
const double fScaleY(aScale.getY() / getContentHeight()); aPageTrans.translate(0.0, fSpaceToAdd * 0.5);
aPageTrans.scale(fScaleX, aScale.getY() / fNeededHeight);
// to keep the aspect, use the smaller scale and adapt missing size by translation
if(fScaleX < fScaleY)
{
// height needs to be adapted
const double fNeededHeight(aScale.getY() / fScaleX);
const double fSpaceToAdd(fNeededHeight - getContentHeight());
aPageTrans.translate(0.0, fSpaceToAdd * 0.5);
aPageTrans.scale(fScaleX, aScale.getY() / fNeededHeight);
}
else
{
// width needs to be adapted
const double fNeededWidth(aScale.getX() / fScaleY);
const double fSpaceToAdd(fNeededWidth - getContentWidth());
aPageTrans.translate(fSpaceToAdd * 0.5, 0.0);
aPageTrans.scale(aScale.getX() / fNeededWidth, fScaleY);
}
// add the missing object transformation aspects
const basegfx::B2DHomMatrix aCombined(basegfx::tools::createShearXRotateTranslateB2DHomMatrix(
fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
aPageTrans = aCombined * aPageTrans;
} }
else else
{ {
// completely scale to PageObject size. Scale to unit size. // width needs to be adapted
aPageTrans.scale(1.0/ getContentWidth(), 1.0 / getContentHeight()); const double fNeededWidth(aScale.getX() / fScaleY);
const double fSpaceToAdd(fNeededWidth - getContentWidth());
// apply object matrix aPageTrans.translate(fSpaceToAdd * 0.5, 0.0);
aPageTrans *= getTransform(); aPageTrans.scale(aScale.getX() / fNeededWidth, fScaleY);
} }
// add the missing object transformation aspects
const basegfx::B2DHomMatrix aCombined(basegfx::tools::createShearXRotateTranslateB2DHomMatrix(
fShearX, fRotate, aTranslate.getX(), aTranslate.getY()));
aPageTrans = aCombined * aPageTrans;
// embed in necessary transformation to map from SdrPage to SdrPageObject // embed in necessary transformation to map from SdrPage to SdrPageObject
const Primitive2DReference xReferenceB(new TransformPrimitive2D(aPageTrans, aContent)); const Primitive2DReference xReferenceB(new TransformPrimitive2D(aPageTrans, aContent));
xRetval = Primitive2DContainer { xReferenceB }; xRetval = Primitive2DContainer { xReferenceB };
...@@ -128,8 +117,7 @@ namespace drawinglayer ...@@ -128,8 +117,7 @@ namespace drawinglayer
maPageContent(rPageContent), maPageContent(rPageContent),
maTransform(rTransform), maTransform(rTransform),
mfContentWidth(fContentWidth), mfContentWidth(fContentWidth),
mfContentHeight(fContentHeight), mfContentHeight(fContentHeight)
mbKeepAspectRatio(true)
{ {
} }
...@@ -143,8 +131,7 @@ namespace drawinglayer ...@@ -143,8 +131,7 @@ namespace drawinglayer
&& getPageContent() == rCompare.getPageContent() && getPageContent() == rCompare.getPageContent()
&& getTransform() == rCompare.getTransform() && getTransform() == rCompare.getTransform()
&& getContentWidth() == rCompare.getContentWidth() && getContentWidth() == rCompare.getContentWidth()
&& getContentHeight() == rCompare.getContentHeight() && getContentHeight() == rCompare.getContentHeight());
&& getKeepAspectRatio() == rCompare.getKeepAspectRatio());
} }
return false; return false;
......
...@@ -47,7 +47,6 @@ namespace drawinglayer ...@@ -47,7 +47,6 @@ namespace drawinglayer
mfDiscreteHitTolerance(0.0), mfDiscreteHitTolerance(0.0),
mbHit(false), mbHit(false),
mbHitToleranceUsed(false), mbHitToleranceUsed(false),
mbUseInvisiblePrimitiveContent(true),
mbHitTextOnly(bHitTextOnly) mbHitTextOnly(bHitTextOnly)
{ {
// init hit tolerance // init hit tolerance
...@@ -506,10 +505,7 @@ namespace drawinglayer ...@@ -506,10 +505,7 @@ namespace drawinglayer
if(!rChildren.empty()) if(!rChildren.empty())
{ {
if(getUseInvisiblePrimitiveContent()) process(rChildren);
{
process(rChildren);
}
} }
break; break;
......
...@@ -41,8 +41,7 @@ namespace drawinglayer ...@@ -41,8 +41,7 @@ namespace drawinglayer
maBack(rBack), maBack(rBack),
maResult(), maResult(),
maCombinedTransform(), maCombinedTransform(),
mbAnyHit(bAnyHit), mbAnyHit(bAnyHit)
mbUseInvisiblePrimitiveContent(true)
{ {
} }
...@@ -123,10 +122,7 @@ namespace drawinglayer ...@@ -123,10 +122,7 @@ namespace drawinglayer
if(!rChildren.empty()) if(!rChildren.empty())
{ {
if(getUseInvisiblePrimitiveContent())
{
process(rChildren); process(rChildren);
}
} }
break; break;
...@@ -138,19 +134,7 @@ namespace drawinglayer ...@@ -138,19 +134,7 @@ namespace drawinglayer
if(rChildren.size()) if(rChildren.size())
{ {
if(1.0 <= rPrimitive.getTransparence()) process(rChildren);
{
// not visible, but use for HitTest
if(getUseInvisiblePrimitiveContent())
{
process(rChildren);
}
}
else if(rPrimitive.getTransparence() >= 0.0 && rPrimitive.getTransparence() < 1.0)
{
// visible; use content
process(rChildren);
}
} }
break; break;
......
...@@ -58,10 +58,6 @@ namespace drawinglayer ...@@ -58,10 +58,6 @@ namespace drawinglayer
double mfContentWidth; double mfContentWidth;
double mfContentHeight; double mfContentHeight;
/// bitfield
/// flag to allow keeping the aspect ratio
bool mbKeepAspectRatio : 1;
protected: protected:
/// local decomposition. Implementation will just return children /// local decomposition. Implementation will just return children
virtual Primitive2DContainer create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override; virtual Primitive2DContainer create2DDecomposition(const geometry::ViewInformation2D& rViewInformation) const override;
...@@ -81,7 +77,6 @@ namespace drawinglayer ...@@ -81,7 +77,6 @@ namespace drawinglayer
const basegfx::B2DHomMatrix& getTransform() const { return maTransform; } const basegfx::B2DHomMatrix& getTransform() const { return maTransform; }
double getContentWidth() const { return mfContentWidth; } double getContentWidth() const { return mfContentWidth; }
double getContentHeight() const { return mfContentHeight; } double getContentHeight() const { return mfContentHeight; }
bool getKeepAspectRatio() const { return mbKeepAspectRatio; }
/// compare operator /// compare operator
virtual bool operator==(const BasePrimitive2D& rPrimitive) const override; virtual bool operator==(const BasePrimitive2D& rPrimitive) const override;
......
...@@ -50,14 +50,6 @@ namespace drawinglayer ...@@ -50,14 +50,6 @@ namespace drawinglayer
bool mbHit : 1; bool mbHit : 1;
bool mbHitToleranceUsed : 1; bool mbHitToleranceUsed : 1;
/* this flag decides if primitives which are embedded to an
UnifiedTransparencePrimitive2D and are invisible will be taken into account for
HitTesting or not. Those primitives are created for objects which are else
completely invisible and normally their content exists of hairline
primitives describing the object's contour
*/
bool mbUseInvisiblePrimitiveContent : 1;
/// flag to concentrate on text hits only /// flag to concentrate on text hits only
bool mbHitTextOnly : 1; bool mbHitTextOnly : 1;
...@@ -83,7 +75,6 @@ namespace drawinglayer ...@@ -83,7 +75,6 @@ namespace drawinglayer
const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; } const basegfx::B2DPoint& getDiscreteHitPosition() const { return maDiscreteHitPosition; }
double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; } double getDiscreteHitTolerance() const { return mfDiscreteHitTolerance; }
bool getHit() const { return mbHit; } bool getHit() const { return mbHit; }
bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;}
bool getHitTextOnly() const { return mbHitTextOnly; } bool getHitTextOnly() const { return mbHitTextOnly; }
}; };
} // end of namespace processor2d } // end of namespace processor2d
......
...@@ -53,11 +53,6 @@ namespace drawinglayer ...@@ -53,11 +53,6 @@ namespace drawinglayer
/// bitfield /// bitfield
bool mbAnyHit : 1; bool mbAnyHit : 1;
/* this flag decides if primitives which are invisible will be taken into account for
HitTesting or not.
*/
bool mbUseInvisiblePrimitiveContent : 1;
/* as tooling, the process() implementation takes over API handling and calls this /* as tooling, the process() implementation takes over API handling and calls this
virtual render method when the primitive implementation is BasePrimitive3D-based. virtual render method when the primitive implementation is BasePrimitive3D-based.
*/ */
...@@ -72,7 +67,6 @@ namespace drawinglayer ...@@ -72,7 +67,6 @@ namespace drawinglayer
/// data read access /// data read access
const ::std::vector< basegfx::B3DPoint >& getCutPoints() const { return maResult; } const ::std::vector< basegfx::B3DPoint >& getCutPoints() const { return maResult; }
bool getAnyHit() const { return mbAnyHit; } bool getAnyHit() const { return mbAnyHit; }
bool getUseInvisiblePrimitiveContent() const { return mbUseInvisiblePrimitiveContent;}
}; };
} // end of namespace processor3d } // end of namespace processor3d
} // end of namespace drawinglayer } // end of namespace drawinglayer
......
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