Skip to content

Build your own AI office with Univer Office SDK. Bring editing, calculation, collaboration, and file processing into your product for people and AI agents. Built on an extensible open-source core.

fix(engine-render): resolve effective group flip state (#7398)

Univer6cd8561ef76a
diff --git a/packages/engine-render/src/base-object.ts b/packages/engine-render/src/base-object.ts
index 84f5d9237e..b1255f3cd8 100644
--- a/packages/engine-render/src/base-object.ts
+++ b/packages/engine-render/src/base-object.ts
@@ -605,6 +605,26 @@ export abstract class BaseObject extends Disposable {
};
}
+ /**
+ * Returns the flip state after composing this object with every ancestor
+ * drawing group whose transform participates in rendering.
+ */
+ getEffectiveFlipState(): { flipX: boolean; flipY: boolean } {
+ let flipX = this.flipX;
+ let flipY = this.flipY;
+ let isInGroup = this.isInGroup;
+ let parent = this.getParent();
+
+ while (isInGroup && parent?.classType === RENDER_CLASS_TYPE.GROUP) {
+ flipX = flipX !== Boolean(parent.flipX);
+ flipY = flipY !== Boolean(parent.flipY);
+ isInGroup = Boolean(parent.isInGroup);
+ parent = parent.getParent();
+ }
+
+ return { flipX, flipY };
+ }
+
getRealBound(): IGroupBaseBound {
let { width: realWidth, height: realHeight, left: realLeft, top: realTop } = this;
let baseBound;