diff options
author | Luboš Luňák <l.lunak@suse.cz> | 2012-05-28 17:21:10 +0200 |
---|---|---|
committer | Luboš Luňák <l.lunak@suse.cz> | 2012-05-28 18:06:15 +0200 |
commit | 5845298e615a599d5edc7c42275b52ae954250e8 (patch) | |
tree | 9e382faf8eb1e9faf55448e1bb21734efa2237df /sw | |
parent | 96c7ab19b77c2f90acd4c34552474b0f616f48a7 (diff) |
fix horizontal rule width in .doc documents (bnc#757118)
MSO uses undocumented properties that seem to map to o:hr and o:hrpct
from .docx (including differences between .docx spec and implementation),
so treat horizontal rule width the same way in .doc too. Also remove
the guesswork for #i17200# that is not quite correct and no longer needed.
Change-Id: Ibec543fa1679ca0b20e86ef6b4f77147b18dff7e
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/filter/ww8/ww8graf2.cxx | 30 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8par.cxx | 12 |
2 files changed, 33 insertions, 9 deletions
diff --git a/sw/source/filter/ww8/ww8graf2.cxx b/sw/source/filter/ww8/ww8graf2.cxx index 3bcbaf73c5ff..93ef5e7a1198 100644 --- a/sw/source/filter/ww8/ww8graf2.cxx +++ b/sw/source/filter/ww8/ww8graf2.cxx @@ -528,15 +528,6 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, // verlinkte Grafik im Escher-Objekt SdrObject* pObject = 0; - //#i17200#, a bit of guesswork I'm afraid - if (aPic.dxaGoal == 1000 && aPic.mx == 1) //100% hack ? - { - aPic.mx = msword_cast<sal_uInt16>( - maSectionManager.GetPageWidth() - - maSectionManager.GetPageRight() - - maSectionManager.GetPageLeft()); - } - WW8PicDesc aPD( aPic ); String aGrName; if (!pMSDffManager) @@ -577,6 +568,27 @@ SwFrmFmt* SwWW8ImplReader::ImportGraf(SdrTextObj* pTextObj, if( pRecord ) { + + // Horizontal rule may have its width given as % of page width + // (-1 is used if not given, 0 means the object has fixed width). + // Additionally, if it's a horizontal rule without width given, + // assume 100.0% width. + int relativeWidth = pRecord->relativeHorizontalWidth; + if( relativeWidth == -1 ) + relativeWidth = pRecord->isHorizontalRule ? 1000 : 0; + if( relativeWidth != 0 ) + { + aPic.mx = msword_cast<sal_uInt16>( + maSectionManager.GetPageWidth() - + maSectionManager.GetPageRight() - + maSectionManager.GetPageLeft()) * relativeWidth / 1000; + aPD = WW8PicDesc( aPic ); + // This SetSnapRect() call adjusts the size of the object itself, + // no idea why it's this call (or even what the call actually does), + // but that's what ImportGraf() (called by ImportObj()) uses. + pObject->SetSnapRect( Rectangle( 0, 0, aPD.nWidth, aPD.nHeight )); + } + //A graphic of this type in this location is always //inline, and uses the pic in the same mould as ww6 //graphics. diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx index fdeafca7769d..1d245c293bb4 100644 --- a/sw/source/filter/ww8/ww8par.cxx +++ b/sw/source/filter/ww8/ww8par.cxx @@ -490,6 +490,18 @@ SdrObject* SwMSDffManager::ProcessObj(SvStream& rSt, *(pImpRec->pYRelTo) = nUDData; break; case 0x03BF: pImpRec->nLayoutInTableCell = nUDData; break; + case 0x0393: + // This seems to correspond to o:hrpct from .docx (even including + // the difference that it's in 0.1% even though the .docx spec + // says it's in 1%). + pImpRec->relativeHorizontalWidth = nUDData; + break; + case 0x0394: + // And this is really just a guess, but a mere presence of this + // flag makes a horizontal rule be as wide as the page (unless + // overriden by something), so it probably matches o:hr from .docx. + pImpRec->isHorizontalRule = true; + break; } if ( rSt.GetError() != 0 ) break; |