[calligra] /: Handle z ordering of anchored shapes correctly like LO do

Thorsten Zachmann t.zachmann at zagge.de
Thu Feb 2 07:51:58 GMT 2012


Hello Boemann,

On Wednesday, February 01, 2012 14:26:00 C. Boemann wrote:
> Git commit 99977b4ac0ea0035422aefdb5cd1f323ec336f36 by C. Boemann.
> Committed on 01/02/2012 at 14:22.
> Pushed by boemann into branch 'master'.
> 
> Handle z ordering of anchored shapes correctly like LO do
> 
> BUG:286589
> 
> M  +11   -2    libs/flake/KoShape.cpp
> M  +8    -0    libs/flake/KoShape.h
> M  +3    -0    plugins/textshape/TextShape.h
> M  +2    -2    words/part/frames/KWFrameLayout.cpp
> 
> http://commits.kde.org/calligra/99977b4ac0ea0035422aefdb5cd1f323ec336f36
> 
> diff --git a/libs/flake/KoShape.cpp b/libs/flake/KoShape.cpp
> index 0abbc9a..5139dc4 100644
> --- a/libs/flake/KoShape.cpp
> +++ b/libs/flake/KoShape.cpp
> @@ -461,6 +461,11 @@ QTransform KoShape::transformation() const
>      return d->localMatrix;
>  }
> 
> +bool KoShape::overruleChildZValues()
> +{
> +    return true;
> +}
> +
>  bool KoShape::compareShapeZIndex(KoShape *s1, KoShape *s2)
>  {
>      bool foundCommonParent = false;
> @@ -479,13 +484,17 @@ bool KoShape::compareShapeZIndex(KoShape *s1, KoShape
> *s2) foundCommonParent = true;
>                  break;
>              }
> -            index2 = parentShapeS2->zIndex();
> +            if (parentShapeS2->overruleChildZValues()) {
> +                index2 = parentShapeS2->zIndex();
> +            }
>              runThrough2 = parentShapeS2->runThrough();
>              parentShapeS2 = parentShapeS2->parent();
>          }
> 
>          if (!foundCommonParent) {
> -            index1 = parentShapeS1->zIndex();
> +            if (parentShapeS1->overruleChildZValues()) {
> +                index1 = parentShapeS1->zIndex();
> +            }
>              runThrough1 = parentShapeS1->runThrough();
>              parentShapeS1 = parentShapeS1->parent();
>          }
> diff --git a/libs/flake/KoShape.h b/libs/flake/KoShape.h
> index 3d774c4..8eb1399 100644
> --- a/libs/flake/KoShape.h
> +++ b/libs/flake/KoShape.h
> @@ -593,6 +593,14 @@ public:
>       */
>      virtual void update(const QRectF &rect) const;
> 
> +   /**
> +    * Returns if during compareShapeZIndex() this shape should overrule
> +    * it childrens z alues with it's own. The default behaviour is to do
> so +    * but for special cases (like Calligra's TextShape) it can be
> overloaded +    * @returns if we overrule z order (default impl. returns
> true) +    */
> +    virtual bool overruleChildZValues();

I think this badly named as the standard is true and that is what we want to 
do. So we don't overrule anything. It is more like that the text shape wants 
to do something special and that should be made clear by the methof

> +
>      /**
>       * This is a method used to sort a list using the STL sorting methods.
>       * @param s1 the first shape
> diff --git a/plugins/textshape/TextShape.h b/plugins/textshape/TextShape.h
> index cad1b29..0272072 100644
> --- a/plugins/textshape/TextShape.h
> +++ b/plugins/textshape/TextShape.h
> @@ -61,6 +61,9 @@ public:
>      /// reimplemented
>      QRectF outlineRect() const;
> 
> +    ///reimplemented
> +    bool overruleChildZValues() {return false;}

I'm not quite sure but I think this should only be done for the main text 
frame in words and not for all shapes. Maybe ignoreParentZValue.

> +
>      /// set the image collection which is needed to draw bullet from
> images void setImageCollection(KoImageCollection *collection) {
> m_imageCollection = collection; }
> 
> diff --git a/words/part/frames/KWFrameLayout.cpp
> b/words/part/frames/KWFrameLayout.cpp index 4699771..fca6501 100644
> --- a/words/part/frames/KWFrameLayout.cpp
> +++ b/words/part/frames/KWFrameLayout.cpp
> @@ -450,10 +450,10 @@ void KWFrameLayout::layoutFramesOnPage(int
> pageNumber) main[i]->shape()->setZIndex(minZIndex);
>      }
>      if (footer && footer->shape()) {
> -        footer->shape()->setZIndex(--minZIndex);
> +        footer->shape()->setZIndex(minZIndex);
>      }
>      if (header && header->shape()) {
> -        header->shape()->setZIndex(--minZIndex);
> +        header->shape()->setZIndex(minZIndex);

2 shapes should never have the same zIndex so the -- was quite correct to do.

>      }
> 
>      if (pageBackground) {

Next time please post such changes to reviewboard before committing them.

Thanks,

Thorsten



More information about the calligra-devel mailing list