diff options
author | ALONSO Laurent <laurent.alonso@inria.fr> | 2019-04-11 10:52:42 +0200 |
---|---|---|
committer | ALONSO Laurent <laurent.alonso@inria.fr> | 2019-04-11 10:52:42 +0200 |
commit | e27270abd5508c9bd7f4d2ea862ffb2ed9977985 (patch) | |
tree | e7872a6fbb59c32076d654bbacf16b8d9bf8dc7c | |
parent | 32d97bc0d377f504a4833da882ee1a33c2e6d1df (diff) |
Simplify a little the code...
Change-Id: Ia1b8c8dacdfa6d79ca5ac06571958e2bff593131
-rw-r--r-- | src/lib/IWORKCollector.cpp | 36 | ||||
-rw-r--r-- | src/lib/IWORKCollector.h | 1 | ||||
-rw-r--r-- | src/lib/KEYCollector.cpp | 8 | ||||
-rw-r--r-- | src/lib/NUM3Parser.cpp | 2 |
4 files changed, 25 insertions, 22 deletions
diff --git a/src/lib/IWORKCollector.cpp b/src/lib/IWORKCollector.cpp index 1df6965..d47ca22 100644 --- a/src/lib/IWORKCollector.cpp +++ b/src/lib/IWORKCollector.cpp @@ -943,6 +943,26 @@ void IWORKCollector::fillLayoutProps(const IWORKStylePtr_t layoutStyle, libreven } } +void IWORKCollector::fillTextAutoSizeProps(const boost::optional<unsigned> &resizeFlags, const IWORKGeometryPtr_t &boundingBox, librevenge::RVNGPropertyList &props) +{ + if (!resizeFlags) return; + unsigned const flags=get(resizeFlags)&3; + // checkme: set "draw:auto-grow-width" to true seems to create too many problems + if ((flags&1)==1 && boundingBox && boundingBox->m_naturalSize.m_width>0) + props.insert("draw:auto-grow-width",false); + if ((flags&2)==0) + props.insert("draw:auto-grow-height",true); + else if (boundingBox && boundingBox->m_naturalSize.m_height>0) + { + props.insert("draw:auto-grow-height",false); + // if ((flags&1)==0) props.insert("draw:auto-grow-width",true); checkme + + // the following seems only use in Impress + props.insert("draw:fit-to-size",true); + props.insert("style:shrink-to-fit",true); + } +} + void IWORKCollector::fillWrapProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, const boost::optional<int> &order) { @@ -1186,13 +1206,7 @@ void IWORKCollector::drawShape(const IWORKShapePtr_t &shape) if (!layoutStyle && bool(shape->m_style) && shape->m_style->has<property::LayoutStyle>()) layoutStyle=shape->m_style->get<property::LayoutStyle>(); fillLayoutProps(layoutStyle, styleProps); - if (shape->m_resizeFlags && (get(shape->m_resizeFlags)&3)==3 && - shape->m_geometry && shape->m_geometry->m_naturalSize.m_width>0 && shape->m_geometry->m_naturalSize.m_height>0) - { - styleProps.insert("draw:auto-grow-height",false); - styleProps.insert("draw:fit-to-size",true); - styleProps.insert("style:shrink-to-fit",true); - } + fillTextAutoSizeProps(shape->m_resizeFlags,shape->m_geometry,styleProps); return drawTextBox(shape->m_text, trafo, shape->m_geometry, styleProps); } @@ -1212,13 +1226,7 @@ void IWORKCollector::drawShape(const IWORKShapePtr_t &shape) if (!layoutStyle && bool(shape->m_style) && shape->m_style->has<property::LayoutStyle>()) layoutStyle=shape->m_style->get<property::LayoutStyle>(); fillLayoutProps(layoutStyle, props); - if (shape->m_resizeFlags && (get(shape->m_resizeFlags)&3)==3 && - shape->m_geometry && shape->m_geometry->m_naturalSize.m_width>0 && shape->m_geometry->m_naturalSize.m_height>0) - { - props.insert("draw:auto-grow-height",false); - props.insert("draw:fit-to-size",true); - props.insert("style:shrink-to-fit",true); - } + fillTextAutoSizeProps(shape->m_resizeFlags,shape->m_geometry,props); drawTextBox(shape->m_text, trafo, shape->m_geometry, props); } } diff --git a/src/lib/IWORKCollector.h b/src/lib/IWORKCollector.h index 45e29d9..8a0b637 100644 --- a/src/lib/IWORKCollector.h +++ b/src/lib/IWORKCollector.h @@ -140,6 +140,7 @@ protected: static void fillGraphicProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, bool isSurface=true, bool isFrame=false); static void fillLayoutProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props); + static void fillTextAutoSizeProps(const boost::optional<unsigned> &resizeFlags, const IWORKGeometryPtr_t &boundingBox, librevenge::RVNGPropertyList &props); static void fillWrapProps(const IWORKStylePtr_t style, librevenge::RVNGPropertyList &props, const boost::optional<int> &order); static void writeFill(const IWORKFill &fill, librevenge::RVNGPropertyList &props); diff --git a/src/lib/KEYCollector.cpp b/src/lib/KEYCollector.cpp index 08dd169..8f5b043 100644 --- a/src/lib/KEYCollector.cpp +++ b/src/lib/KEYCollector.cpp @@ -177,13 +177,7 @@ void KEYCollector::insertTextPlaceholder(const KEYPlaceholderPtr_t &placeholder) { librevenge::RVNGPropertyList props; fillLayoutProps(placeholder->m_style, props); - if (placeholder->m_resizeFlags && (get(placeholder->m_resizeFlags)&3)==3 && - placeholder->m_geometry && placeholder->m_geometry->m_naturalSize.m_width>0 && placeholder->m_geometry->m_naturalSize.m_height>0) - { - props.insert("draw:auto-grow-height",false); - props.insert("draw:fit-to-size",true); - props.insert("style:shrink-to-fit",true); - } + fillTextAutoSizeProps(placeholder->m_resizeFlags,placeholder->m_geometry,props); drawTextBox(placeholder->m_text, trafo, placeholder->m_geometry, props); } } diff --git a/src/lib/NUM3Parser.cpp b/src/lib/NUM3Parser.cpp index 578843a..66fb195 100644 --- a/src/lib/NUM3Parser.cpp +++ b/src/lib/NUM3Parser.cpp @@ -42,7 +42,7 @@ bool NUM3Parser::parseSheet(unsigned id) return true; } -bool NUM3Parser::parseShapePlacement(const IWAMessage &msg, IWORKGeometryPtr_t &geometry, boost::optional<unsigned> &flags) +bool NUM3Parser::parseShapePlacement(const IWAMessage &msg, IWORKGeometryPtr_t &geometry, boost::optional<unsigned> &) { geometry = std::make_shared<IWORKGeometry>(); const boost::optional<IWAMessage> &g = msg.message(1).optional(); |