void KWRootAreaProviderBase::doPostLayout(KoTextLayoutRootArea *rootArea, bool /*isNewRootArea*/) { KoShape *shape = rootArea->associatedShape(); if (!shape) { return; } KoTextShapeData *data = qobject_cast<KoTextShapeData*>(shape->userData()); Q_ASSERT(data); QRectF updateRect = shape->outlineRect(); QSizeF newSize = shape->size() - QSizeF(data->leftPadding() + data->rightPadding(), data->topPadding() + data->bottomPadding()); KoBorder *border = shape->border(); if (border) { newSize -= QSizeF(border->borderWidth(KoBorder::LeftBorder) + border->borderWidth(KoBorder::RightBorder), border->borderWidth(KoBorder::TopBorder) + border->borderWidth(KoBorder::BottomBorder)); } if (data->resizeMethod() == KoTextShapeData::AutoGrowWidthAndHeight ||data->resizeMethod() == KoTextShapeData::AutoGrowHeight) { newSize.setHeight(rootArea->bottom() - rootArea->top()); // adjust size to have at least the defined minimum height Q_ASSERT(frameSet()->shapeCount() > 0); KoShape *firstShape = frameSet()->shapes().first(); if (firstShape->minimumHeight() > newSize.height()) newSize.setHeight(firstShape->minimumHeight()); } if (data->resizeMethod() == KoTextShapeData::AutoGrowWidthAndHeight ||data->resizeMethod() == KoTextShapeData::AutoGrowWidth) { newSize.setWidth(rootArea->right() - rootArea->left()); } newSize += QSizeF(data->leftPadding() + data->rightPadding(), data->topPadding() + data->bottomPadding()); if (border) { newSize += QSizeF(border->borderWidth(KoBorder::LeftBorder) + border->borderWidth(KoBorder::RightBorder), border->borderWidth(KoBorder::TopBorder) + border->borderWidth(KoBorder::BottomBorder)); } if (newSize != rootArea->associatedShape()->size()) { rootArea->associatedShape()->setSize(newSize); // transfer the new size to the copy-shapes foreach(KWCopyShape *cs, frameSet()->copyShapes()) { cs->setSize(newSize); }
void ShrinkToFitShapeContainer::tryWrapShape(KoShape *shape, const KoXmlElement &element, KoShapeLoadingContext &context) { KoTextShapeData* data = dynamic_cast<KoTextShapeData*>(shape->userData()); if (!data || data->resizeMethod() != KoTextShapeData::ShrinkToFitResize) return; KoShapeContainer *oldParent = shape->parent(); ShrinkToFitShapeContainer *tos = wrapShape(shape, context.documentResourceManager()); if (!tos->loadOdf(element, context)) { shape->setParent(oldParent); delete tos; } }