diff options
author | Sebastian Geerken <devnull@localhost> | 2015-12-30 23:23:26 +0100 |
---|---|---|
committer | Sebastian Geerken <devnull@localhost> | 2015-12-30 23:23:26 +0100 |
commit | 0a654860a53d5f44276d2637901feee5cba46747 (patch) | |
tree | 3f5f976633bda3145bd796aa4f7d19c06f7438a1 /dw/ooffloatsmgr.cc | |
parent | 91ae5fed75491a199a86372648956db16bcdaf7d (diff) |
SRDOP: fix floats within textblocks not necessarily allocating the availabke width.
Diffstat (limited to 'dw/ooffloatsmgr.cc')
-rw-r--r-- | dw/ooffloatsmgr.cc | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/dw/ooffloatsmgr.cc b/dw/ooffloatsmgr.cc index 65c6c3ed..5b4aee9a 100644 --- a/dw/ooffloatsmgr.cc +++ b/dw/ooffloatsmgr.cc @@ -419,9 +419,11 @@ void OOFFloatsMgr::sizeAllocateFloats (Side side) int OOFFloatsMgr::calcFloatX (Float *vloat) { DBG_OBJ_ENTER ("resize.common", 0, "calcFloatX", "%p", vloat->getWidget ()); - int x; + int x, effGeneratorWidth; OOFAwareWidget *generator = vloat->generator; + ensureFloatSize (vloat); + switch (vloat->getWidget()->getStyle()->vloat) { case FLOAT_LEFT: // Left floats are always aligned on the left side of the generator @@ -432,17 +434,40 @@ int OOFFloatsMgr::calcFloatX (Float *vloat) // ... but when the float exceeds the line break width of the container, // it is corrected (but not left of the container). This way, we save // space and, especially within tables, avoid some problems. - if (x + vloat->size.width > container->getGeneratorWidth ()) - x = max (0, container->getGeneratorWidth () - vloat->size.width); + if (x + vloat->size.width > container->getMaxGeneratorWidth ()) + x = max (0, container->getMaxGeneratorWidth () - vloat->size.width); break; case FLOAT_RIGHT: // Similar for right floats, but in this case, floats are shifted to the // right when they are too big (instead of shifting the generator to the // right). - x = max (generator->getGeneratorX (oofmIndex) - + generator->getGeneratorWidth () - vloat->size.width - - generator->getStyle()->boxRestWidth(), + + // (The following code for calculating effGeneratorWidth, is quite + // specific for textblocks; this also applies for the comments. Both may + // be generalized, but actually, only textblocks play a role here.) + + if (vloat->generator->usesMaxGeneratorWidth ()) + // For most textblocks, the line break width is used for calculating + // the x position. (This changed for GROWS, where the width of a + // textblock is often smaller that the line break.) + effGeneratorWidth = vloat->generator->getMaxGeneratorWidth (); + else + // For some textblocks, like inline blocks, the line break width would + // be too large for right floats in some cases. + // + // (i) Consider a small inline block with only a few words in one + // line, narrower that line break width minus float width. In this + // case, the sum should be used. + // + // (ii) If there is more than one line, the line break will already be + // exceeded, and so be smaller that GB width + float width. + effGeneratorWidth = + min (vloat->generator->getGeneratorWidth () + vloat->size.width, + vloat->generator->getMaxGeneratorWidth ()); + + x = max (generator->getGeneratorX (oofmIndex) + effGeneratorWidth + - vloat->size.width - generator->getStyle()->boxRestWidth(), // Do not exceed container allocation: 0); break; @@ -453,7 +478,7 @@ int OOFFloatsMgr::calcFloatX (Float *vloat) break; } - DBG_OBJ_LEAVE (); + DBG_OBJ_LEAVE_VAL ("%d", x); return x; } |