diff options
author | Miklos Vajna <vmiklos@collabora.com> | 2020-09-11 17:30:27 +0200 |
---|---|---|
committer | Miklos Vajna <vmiklos@collabora.com> | 2020-09-11 20:07:17 +0200 |
commit | 1bd3474c7c7945e1182dfbaca89be05ea98dd3e8 (patch) | |
tree | 2a8908c145c132cf8d635a1051b10f129a6a8b13 /include | |
parent | e9b9044f7b7b44b45dd582885cad0b0a7d44f88b (diff) |
oox smartart: add support for syncing font heights of multiple shapes
When 2 or more shapes have their text set to autofit and they have a
constraint like:
<dgm:constr type="primFontSz" for="des" forName="node" op="equ"/>
Then make sure that the automatic font size is the same for all shapes
and all content fits, by using the smallest scaling factor from all
relevant shapes.
Some rework is needed, because normally oox::drawingml::Shapes don't
have access to their parents, at the same time there can be multiple
SmartArts on a single slide, so storing the grouping info in the filter
is problematic, too. Solve this by storing the grouping in the toplevel
oox::drawingml::Shape and exposing them in XmlFilterBase just during the
time the children of the toplevel shape of the SmartArt are added.
This works, because we know SmartArts can't be nested.
Change-Id: I6c591eadc7166c7c42752650afdb7ee1e416cff6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102490
Reviewed-by: Miklos Vajna <vmiklos@collabora.com>
Tested-by: Jenkins
Diffstat (limited to 'include')
-rw-r--r-- | include/oox/core/xmlfilterbase.hxx | 12 | ||||
-rw-r--r-- | include/oox/drawingml/shape.hxx | 8 |
2 files changed, 20 insertions, 0 deletions
diff --git a/include/oox/core/xmlfilterbase.hxx b/include/oox/core/xmlfilterbase.hxx index bad90cc0d132..99b73e5b18bd 100644 --- a/include/oox/core/xmlfilterbase.hxx +++ b/include/oox/core/xmlfilterbase.hxx @@ -64,6 +64,11 @@ namespace sax_fastparser { namespace utl { class MediaDescriptor; } +namespace oox::drawingml +{ +class Shape; +} + namespace oox::core { class FragmentHandler; @@ -78,6 +83,10 @@ typedef std::vector< TextField > TextFieldStack; struct XmlFilterBaseImpl; +using ShapePairs + = std::map<std::shared_ptr<drawingml::Shape>, css::uno::Reference<css::drawing::XShape>>; +using NamedShapePairs = std::map<OUString, ShapePairs>; + class OOX_DLLPUBLIC XmlFilterBase : public FilterBase { public: @@ -241,6 +250,9 @@ public: /// user about it. void setMissingExtDrawing(); + void setDiagramFontHeights(NamedShapePairs* pDiagramFontHeights); + NamedShapePairs* getDiagramFontHeights(); + void checkDocumentProperties( const css::uno::Reference<css::document::XDocumentProperties>& xDocProps); diff --git a/include/oox/drawingml/shape.hxx b/include/oox/drawingml/shape.hxx index b1f15e5b6ece..fea94105b65d 100644 --- a/include/oox/drawingml/shape.hxx +++ b/include/oox/drawingml/shape.hxx @@ -29,6 +29,8 @@ #include <com/sun/star/beans/PropertyValue.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/uno/Sequence.hxx> + +#include <oox/core/xmlfilterbase.hxx> #include <oox/dllapi.h> #include <oox/drawingml/color.hxx> #include <oox/drawingml/drawingmltypes.hxx> @@ -239,6 +241,8 @@ public: void keepDiagramDrawing(::oox::core::XmlFilterBase& rFilterBase, const OUString& rFragmentPath); + oox::core::NamedShapePairs& getDiagramFontHeights() { return maDiagramFontHeights; } + protected: enum FrameType @@ -272,6 +276,7 @@ protected: const basegfx::B2DHomMatrix& aTransformation ); void keepDiagramCompatibilityInfo(); + void syncDiagramFontHeights(); void convertSmartArtToMetafile( ::oox::core::XmlFilterBase const& rFilterBase ); css::uno::Reference< css::drawing::XShape > @@ -377,6 +382,9 @@ private: /// The shape fill should be set to that of the slide background surface. bool mbUseBgFill = false; + + /// For SmartArt, this contains groups of shapes: automatic font size is the same in each group. + oox::core::NamedShapePairs maDiagramFontHeights; }; } |