summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuboš Luňák <l.lunak@suse.cz>2012-05-28 17:21:10 +0200
committerLuboš Luňák <l.lunak@suse.cz>2012-05-28 18:06:15 +0200
commit5845298e615a599d5edc7c42275b52ae954250e8 (patch)
tree9e382faf8eb1e9faf55448e1bb21734efa2237df
parent96c7ab19b77c2f90acd4c34552474b0f616f48a7 (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
-rw-r--r--filter/inc/filter/msfilter/msdffimp.hxx2
-rw-r--r--filter/source/msfilter/msdffimp.cxx20
-rw-r--r--sw/source/filter/ww8/ww8graf2.cxx30
-rw-r--r--sw/source/filter/ww8/ww8par.cxx12
4 files changed, 53 insertions, 11 deletions
diff --git a/filter/inc/filter/msfilter/msdffimp.hxx b/filter/inc/filter/msfilter/msdffimp.hxx
index ad2e55ae8c7c..db15f86c8517 100644
--- a/filter/inc/filter/msfilter/msdffimp.hxx
+++ b/filter/inc/filter/msfilter/msdffimp.hxx
@@ -319,6 +319,8 @@ struct MSFILTER_DLLPUBLIC SvxMSDffImportRec
sal_Bool bVFlip :1;
sal_Bool bHFlip :1;
sal_Bool bAutoWidth :1;
+ int relativeHorizontalWidth; // in 0.1% or -1 for none
+ bool isHorizontalRule;
SvxMSDffImportRec();
SvxMSDffImportRec(const SvxMSDffImportRec& rCopy);
diff --git a/filter/source/msfilter/msdffimp.cxx b/filter/source/msfilter/msdffimp.cxx
index 49ba21176c46..9d5e1dc64fb5 100644
--- a/filter/source/msfilter/msdffimp.cxx
+++ b/filter/source/msfilter/msdffimp.cxx
@@ -5209,6 +5209,18 @@ SdrObject* SvxMSDffManager::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;
@@ -7507,7 +7519,9 @@ SvxMSDffImportRec::SvxMSDffImportRec()
aTextId( 0, 0 ),
nNextShapeId( 0 ),
nShapeId( 0 ),
- eShapeType( mso_sptNil )
+ eShapeType( mso_sptNil ),
+ relativeHorizontalWidth( -1 ),
+ isHorizontalRule( false )
{
eLineStyle = mso_lineSimple; // GPF-Bug #66227#
eLineDashing = mso_lineSolid;
@@ -7545,7 +7559,9 @@ SvxMSDffImportRec::SvxMSDffImportRec(const SvxMSDffImportRec& rCopy)
aTextId( rCopy.aTextId ),
nNextShapeId( rCopy.nNextShapeId ),
nShapeId( rCopy.nShapeId ),
- eShapeType( rCopy.eShapeType )
+ eShapeType( rCopy.eShapeType ),
+ relativeHorizontalWidth( rCopy.relativeHorizontalWidth ),
+ isHorizontalRule( rCopy.isHorizontalRule )
{
if (rCopy.pXRelTo)
{
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;