diff --git a/MsBinaryFile/DocFile/BorderCode.cpp b/MsBinaryFile/DocFile/BorderCode.cpp index b47e30440c..7e175d3883 100644 --- a/MsBinaryFile/DocFile/BorderCode.cpp +++ b/MsBinaryFile/DocFile/BorderCode.cpp @@ -66,7 +66,10 @@ namespace DocFileFormat brcType = bytes[5]; short val = FormatUtils::BytesToInt16( bytes, 6, size ); - dptSpace = val & 0x001F; + if (val == -1) + dptSpace = 0; + else + dptSpace = val & 0x001F; //not sure if this is correct, the values from the spec are definitly wrong: fShadow = FormatUtils::BitmaskToBool( val, 0x20 ); diff --git a/MsBinaryFile/DocFile/DocumentMapping.cpp b/MsBinaryFile/DocFile/DocumentMapping.cpp index 9d57310354..d0f9dc6c61 100644 --- a/MsBinaryFile/DocFile/DocumentMapping.cpp +++ b/MsBinaryFile/DocFile/DocumentMapping.cpp @@ -338,6 +338,7 @@ namespace DocFileFormat if ((chpxs != NULL) && (chpxFcs != NULL) && !chpxFcs->empty())//? второе { size_t i = 0; + bool changechpx = false; // write a runs for each CHPX for (size_t it = 0; it < chpxs->size(); ++it) @@ -346,9 +347,18 @@ namespace DocFileFormat int fcChpxStart = ((chpxFcs) && (i < chpxFcs->size())) ? chpxFcs->at(i) : fc; int fcChpxEnd = fcEnd; - - if ((chpxFcs) && ( i < chpxFcs->size() - 1)) - fcChpxEnd = chpxFcs->at(i + 1); + if (i > 0) + { + int previous = chpxFcs->at(i-1); + if ((fcChpxStart != fc) && (previous > fcChpxStart)) + { + fcChpxStart = previous; + changechpx = true; + } + } + + if ((chpxFcs) && ( i < chpxFcs->size() - 1)) + fcChpxEnd = chpxFcs->at(i + 1); //it's the first chpx and it starts before the paragraph @@ -427,7 +437,13 @@ namespace DocFileFormat } else { - cp = writeRun(chpxChars, chpxs->at(it), cp); + if (changechpx == true) + { + size_t a = it - 1; + cp = writeRun(chpxChars, chpxs->at(a), cp); + } + else + cp = writeRun(chpxChars, chpxs->at(it), cp); } } }