tdf#91261: DOCX import: snapGrid property of paragraphs are ignored
Fix the situation for OOXML import filter: a) While handling DocGrid type, SnapToChars was treated as None. Now it is implemented as described in the article: http://linpeifeng.blogspot.tw/2007/02/text-grid-enhancement.html Both LinesAndChars and SnapToChars will be translated to Writer grid type "lines and characters", and set SnapToGrid property to false or true accordingly. b) All the imported paragraphs snap to grid because SnapToGrid was appended to grabbag, now it allows SnapToGrid property in paragraph and paragraph styles to be imported properly. Change-Id: I446b4c64c0ed86960896bcd61a1006c9173a757a Reviewed-on: https://gerrit.libreoffice.org/15732 Reviewed-by: Michael Stahl <mstahl@redhat.com> Tested-by: Michael Stahl <mstahl@redhat.com>
This commit is contained in:
BIN
sw/qa/extras/ooxmlexport/data/tdf91261.docx
Normal file
BIN
sw/qa/extras/ooxmlexport/data/tdf91261.docx
Normal file
Binary file not shown.
@@ -676,6 +676,25 @@ DECLARE_OOXMLEXPORT_TEST(testTdf89791, "tdf89791.docx")
|
||||
}
|
||||
}
|
||||
|
||||
DECLARE_OOXMLEXPORT_TEST(testTdf91261, "tdf91261.docx")
|
||||
{
|
||||
bool snapToGrid = true;
|
||||
uno::Reference< text::XTextRange > xPara = getParagraph( 2 );
|
||||
uno::Reference< beans::XPropertySet > properties( xPara, uno::UNO_QUERY);
|
||||
properties->getPropertyValue("SnapToGrid") >>= snapToGrid ;
|
||||
CPPUNIT_ASSERT_EQUAL(false, snapToGrid);
|
||||
|
||||
uno::Reference< beans::XPropertySet> xStyle(getStyles("PageStyles")->getByName("Standard"), uno::UNO_QUERY);
|
||||
sal_Int16 nGridMode;
|
||||
xStyle->getPropertyValue("GridMode") >>= nGridMode;
|
||||
CPPUNIT_ASSERT_EQUAL( sal_Int16(2), nGridMode);
|
||||
|
||||
bool bGridSnapToChars;
|
||||
xStyle->getPropertyValue("GridSnapToChars") >>= bGridSnapToChars;
|
||||
CPPUNIT_ASSERT_EQUAL(true, bGridSnapToChars);
|
||||
|
||||
}
|
||||
|
||||
CPPUNIT_PLUGIN_IMPLEMENT();
|
||||
|
||||
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|
||||
|
@@ -934,14 +934,18 @@ void DomainMapper::lcl_attribute(Id nName, Value & val)
|
||||
switch( nIntValue )
|
||||
{
|
||||
case NS_ooxml::LN_Value_doc_ST_DocGrid_default:
|
||||
case NS_ooxml::LN_Value_doc_ST_DocGrid_snapToChars:
|
||||
pSectionContext->SetGridType( 0 );
|
||||
pSectionContext->SetGridType(text::TextGridMode::NONE);
|
||||
break;
|
||||
case NS_ooxml::LN_Value_doc_ST_DocGrid_lines:
|
||||
pSectionContext->SetGridType( 1 );
|
||||
pSectionContext->SetGridType(text::TextGridMode::LINES);
|
||||
break;
|
||||
case NS_ooxml::LN_Value_doc_ST_DocGrid_linesAndChars:
|
||||
pSectionContext->SetGridType( 2 );
|
||||
pSectionContext->SetGridType(text::TextGridMode::LINES_AND_CHARS);
|
||||
pSectionContext->SetGridSnapToChars( false );
|
||||
break;
|
||||
case NS_ooxml::LN_Value_doc_ST_DocGrid_snapToChars:
|
||||
pSectionContext->SetGridType(text::TextGridMode::LINES_AND_CHARS);
|
||||
pSectionContext->SetGridSnapToChars( true );
|
||||
break;
|
||||
default :
|
||||
OSL_FAIL("unknown SwTextGrid value");
|
||||
@@ -2005,7 +2009,14 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext )
|
||||
break;
|
||||
|
||||
case NS_ooxml::LN_CT_PPrBase_snapToGrid:
|
||||
if (!IsStyleSheetImport()||!m_pImpl->isInteropGrabBagEnabled())
|
||||
{
|
||||
rContext->Insert( PROP_SNAP_TO_GRID, uno::makeAny(bool(nIntValue)));
|
||||
}
|
||||
else
|
||||
{
|
||||
m_pImpl->appendGrabBag(m_pImpl->m_aInteropGrabBag, "snapToGrid", OUString::number(nIntValue));
|
||||
}
|
||||
break;
|
||||
case NS_ooxml::LN_CT_PPrBase_pStyle:
|
||||
{
|
||||
|
@@ -403,6 +403,8 @@ OUString PropertyNameSupplier::GetName( PropertyIds eId ) const
|
||||
case PROP_FOLLOW_TEXT_FLOW: sName = "IsFollowingTextFlow"; break;
|
||||
case PROP_FILL_STYLE: sName = "FillStyle"; break;
|
||||
case PROP_FILL_COLOR: sName = "FillColor"; break;
|
||||
case PROP_SNAP_TO_GRID: sName = "SnapToGrid"; break;
|
||||
case PROP_GRID_SNAP_TO_CHARS: sName = "GridSnapToChars"; break;
|
||||
}
|
||||
::std::pair<PropertyNameMap_t::iterator,bool> aInsertIt =
|
||||
m_pImpl->aNameMap.insert( PropertyNameMap_t::value_type( eId, sName ));
|
||||
|
@@ -377,6 +377,8 @@ enum PropertyIds
|
||||
,PROP_FOLLOW_TEXT_FLOW
|
||||
,PROP_FILL_STYLE
|
||||
,PROP_FILL_COLOR
|
||||
,PROP_SNAP_TO_GRID
|
||||
,PROP_GRID_SNAP_TO_CHARS
|
||||
};
|
||||
struct PropertyNameSupplier_Impl;
|
||||
class PropertyNameSupplier
|
||||
|
@@ -427,6 +427,7 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) :
|
||||
,m_nGridType(0)
|
||||
,m_nGridLinePitch( 1 )
|
||||
,m_nDxtCharSpace( 0 )
|
||||
,m_bGridSnapToChars(true)
|
||||
,m_nLnnMod( 0 )
|
||||
,m_nLnc( 0 )
|
||||
,m_ndxaLnn( 0 )
|
||||
@@ -1168,6 +1169,10 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl )
|
||||
|
||||
// PROP_GRID_MODE
|
||||
Insert( PROP_GRID_MODE, uno::makeAny( static_cast<sal_Int16> (m_nGridType) ));
|
||||
if (m_nGridType == text::TextGridMode::LINES_AND_CHARS)
|
||||
{
|
||||
Insert( PROP_GRID_SNAP_TO_CHARS, uno::makeAny(m_bGridSnapToChars));
|
||||
}
|
||||
|
||||
sal_Int32 nCharWidth = 423; //240 twip/ 12 pt
|
||||
//todo: is '0' the right index here?
|
||||
|
@@ -230,6 +230,7 @@ class SectionPropertyMap : public PropertyMap
|
||||
sal_Int32 m_nGridType;
|
||||
sal_Int32 m_nGridLinePitch;
|
||||
sal_Int32 m_nDxtCharSpace;
|
||||
bool m_bGridSnapToChars;
|
||||
|
||||
//line numbering
|
||||
sal_Int32 m_nLnnMod;
|
||||
@@ -312,6 +313,7 @@ public:
|
||||
|
||||
void SetGridType(sal_Int32 nSet) { m_nGridType = nSet; }
|
||||
void SetGridLinePitch( sal_Int32 nSet ) { m_nGridLinePitch = nSet; }
|
||||
void SetGridSnapToChars( bool bSet) { m_bGridSnapToChars = bSet; }
|
||||
void SetDxtCharSpace( sal_Int32 nSet ) { m_nDxtCharSpace = nSet; }
|
||||
|
||||
void SetLnnMod( sal_Int32 nValue ) { m_nLnnMod = nValue; }
|
||||
|
Reference in New Issue
Block a user