[Libreoffice-commits] .: Branch 'libreoffice-3-6' - 8 commits - oox/inc oox/source sw/qa sw/source writerfilter/source
Miklos Vajna
vmiklos at kemper.freedesktop.org
Fri Jun 22 08:45:25 PDT 2012
oox/inc/oox/vml/vmlshape.hxx | 2
oox/source/vml/vmlshape.cxx | 33 ++++++++++++--
oox/source/vml/vmlshapecontext.cxx | 7 +++
sw/qa/extras/rtfexport/data/fdo50831.rtf | 11 ++++
sw/qa/extras/rtfexport/rtfexport.cxx | 15 ++++++
sw/source/filter/ww8/attributeoutputbase.hxx | 2
sw/source/filter/ww8/docxattributeoutput.cxx | 2
sw/source/filter/ww8/docxattributeoutput.hxx | 2
sw/source/filter/ww8/rtfattributeoutput.cxx | 12 +++--
sw/source/filter/ww8/rtfattributeoutput.hxx | 5 +-
sw/source/filter/ww8/wrtw8nds.cxx | 7 +--
sw/source/filter/ww8/ww8atr.cxx | 2
sw/source/filter/ww8/ww8attributeoutput.hxx | 2
writerfilter/source/dmapper/DomainMapper.cxx | 26 ++++++++---
writerfilter/source/dmapper/DomainMapper_Impl.cxx | 42 ++++++++++++++++++
writerfilter/source/dmapper/DomainMapper_Impl.hxx | 2
writerfilter/source/dmapper/OLEHandler.cxx | 14 ++++--
writerfilter/source/dmapper/PropertyMap.cxx | 13 +++--
writerfilter/source/dmapper/PropertyMap.hxx | 2
writerfilter/source/ooxml/OOXMLFastContextHandler.cxx | 7 ++-
20 files changed, 174 insertions(+), 34 deletions(-)
New commits:
commit bd9a96fcd642ffa0260a8684eb5dfa9061c40c71
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Fri Jun 22 15:41:37 2012 +0200
fdo#50831 fix RTF export of direct run formatting for empty paragraphs
Change-Id: I5f0e7aefdea80bbb9cf61b991c5b706bd2023dfa
diff --git a/sw/qa/extras/rtfexport/data/fdo50831.rtf b/sw/qa/extras/rtfexport/data/fdo50831.rtf
new file mode 100644
index 0000000..476a82f
--- /dev/null
+++ b/sw/qa/extras/rtfexport/data/fdo50831.rtf
@@ -0,0 +1,11 @@
+{\rtf1\ansi\deff3\adeflang1025
+{\fonttbl
+{\f0\froman\fprq2\fcharset0 Times New Roman;}
+{\f4\fswiss\fprq2\fcharset0 Arial;}
+}
+\pard\plain
+\fs20\loch\f4
+\par \pard\plain
+{\fs20\f4
+Foo}
+\par}
diff --git a/sw/qa/extras/rtfexport/rtfexport.cxx b/sw/qa/extras/rtfexport/rtfexport.cxx
index 6df0aec..428b7e1 100644
--- a/sw/qa/extras/rtfexport/rtfexport.cxx
+++ b/sw/qa/extras/rtfexport/rtfexport.cxx
@@ -48,6 +48,7 @@ public:
void testFdo49683();
void testFdo44174();
void testFdo50087();
+ void testFdo50831();
CPPUNIT_TEST_SUITE(Test);
#if !defined(MACOSX) && !defined(WNT)
@@ -56,6 +57,7 @@ public:
CPPUNIT_TEST(testFdo49683);
CPPUNIT_TEST(testFdo44174);
CPPUNIT_TEST(testFdo50087);
+ CPPUNIT_TEST(testFdo50831);
#endif
CPPUNIT_TEST_SUITE_END();
@@ -129,6 +131,19 @@ void Test::testFdo50087()
CPPUNIT_ASSERT_EQUAL(OUString("First line.\nSecond line."), xDocumentProperties->getDescription());
}
+void Test::testFdo50831()
+{
+ roundtrip("fdo50831.rtf");
+
+ uno::Reference<text::XTextDocument> xTextDocument(mxComponent, uno::UNO_QUERY);
+ uno::Reference<container::XEnumerationAccess> xParaEnumAccess(xTextDocument->getText(), uno::UNO_QUERY);
+ uno::Reference<container::XEnumeration> xParaEnum = xParaEnumAccess->createEnumeration();
+ uno::Reference<beans::XPropertySet> xPropertySet(xParaEnum->nextElement(), uno::UNO_QUERY);
+ float fValue = 0;
+ xPropertySet->getPropertyValue("CharHeight") >>= fValue;
+ CPPUNIT_ASSERT_EQUAL(10.f, fValue);
+}
+
CPPUNIT_TEST_SUITE_REGISTRATION(Test);
CPPUNIT_PLUGIN_IMPLEMENT();
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index 4b08cbf..c257a02 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -159,7 +159,7 @@ public:
virtual void EmptyParagraph() = 0;
/// Start of the text run.
- virtual void StartRun( const SwRedlineData* pRedlineData ) = 0;
+ virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false ) = 0;
/// End of the text run.
virtual void EndRun() = 0;
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 0d94c30..e2406d1 100644
--- a/sw/source/filter/ww8/docxattributeoutput.cxx
+++ b/sw/source/filter/ww8/docxattributeoutput.cxx
@@ -500,7 +500,7 @@ void DocxAttributeOutput::EndParagraphProperties()
m_pSerializer->mergeTopMarks( sax_fastparser::MERGE_MARKS_PREPEND );
}
-void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
+void DocxAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
{
// if there is some redlining in the document, output it
StartRedline( pRedlineData );
diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx
index 11b8cee..3c855cf 100644
--- a/sw/source/filter/ww8/docxattributeoutput.hxx
+++ b/sw/source/filter/ww8/docxattributeoutput.hxx
@@ -90,7 +90,7 @@ public:
virtual void EndParagraphProperties();
/// Start of the text run.
- virtual void StartRun( const SwRedlineData* pRedlineData );
+ virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
/// End of the text run.
virtual void EndRun();
diff --git a/sw/source/filter/ww8/rtfattributeoutput.cxx b/sw/source/filter/ww8/rtfattributeoutput.cxx
index c8efc82..9380cca 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.cxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.cxx
@@ -379,11 +379,13 @@ void RtfAttributeOutput::EndParagraphProperties()
m_rExport.Strm() << m_aStyles.makeStringAndClear().getStr();
}
-void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData )
+void RtfAttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun )
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
- m_aRun->append('{');
+ m_bSingleEmptyRun = bSingleEmptyRun;
+ if (!m_bSingleEmptyRun)
+ m_aRun->append('{');
// if there is some redlining in the document, output it
Redline( pRedlineData );
@@ -396,7 +398,8 @@ void RtfAttributeOutput::EndRun()
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
m_aRun->append(m_rExport.sNewLine);
m_aRun.appendAndClear(m_aRunText);
- m_aRun->append('}');
+ if (!m_bSingleEmptyRun)
+ m_aRun->append('}');
}
void RtfAttributeOutput::StartRunProperties()
@@ -3025,7 +3028,8 @@ RtfAttributeOutput::RtfAttributeOutput( RtfExport &rExport )
m_bWroteCellInfo( false ),
m_bHadFieldResult( false ),
m_bTableRowEnded( false ),
- m_aCells()
+ m_aCells(),
+ m_bSingleEmptyRun(false)
{
SAL_INFO("sw.rtf", OSL_THIS_FUNC);
}
diff --git a/sw/source/filter/ww8/rtfattributeoutput.hxx b/sw/source/filter/ww8/rtfattributeoutput.hxx
index 4be68db..3957de5 100644
--- a/sw/source/filter/ww8/rtfattributeoutput.hxx
+++ b/sw/source/filter/ww8/rtfattributeoutput.hxx
@@ -65,7 +65,7 @@ public:
virtual void EndParagraphProperties();
/// Start of the text run.
- virtual void StartRun( const SwRedlineData* pRedlineData );
+ virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
/// End of the text run.
virtual void EndRun();
@@ -541,6 +541,9 @@ private:
/// Number of cells from the table definition, by depth.
std::map<sal_uInt32,sal_uInt32> m_aCells;
+
+ /// If we're in a paragraph that has a single empty run only.
+ bool m_bSingleEmptyRun;
public:
RtfAttributeOutput( RtfExport &rExport );
diff --git a/sw/source/filter/ww8/wrtw8nds.cxx b/sw/source/filter/ww8/wrtw8nds.cxx
index 988c3d0..adeeb5a 100644
--- a/sw/source/filter/ww8/wrtw8nds.cxx
+++ b/sw/source/filter/ww8/wrtw8nds.cxx
@@ -1806,12 +1806,13 @@ void MSWordExportBase::OutputTextNode( const SwTxtNode& rNode )
do {
const SwRedlineData* pRedlineData = aAttrIter.GetRedline( nAktPos );
- AttrOutput().StartRun( pRedlineData );
+ xub_StrLen nNextAttr = GetNextPos( &aAttrIter, rNode, nAktPos );
+ // Is this the only run in this paragraph and it's empty?
+ bool bSingleEmptyRun = nAktPos == 0 && nNextAttr == 0;
+ AttrOutput().StartRun( pRedlineData, bSingleEmptyRun );
if( nTxtTyp == TXT_FTN || nTxtTyp == TXT_EDN )
AttrOutput().FootnoteEndnoteRefTag();
- xub_StrLen nNextAttr = GetNextPos( &aAttrIter, rNode, nAktPos );
-
if( nNextAttr > nEnd )
nNextAttr = nEnd;
diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx
index 52cc2bc..40e85b6 100644
--- a/sw/source/filter/ww8/ww8atr.cxx
+++ b/sw/source/filter/ww8/ww8atr.cxx
@@ -972,7 +972,7 @@ void WW8AttributeOutput::StartRunProperties()
}
-void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData )
+void WW8AttributeOutput::StartRun( const SwRedlineData* pRedlineData, bool /*bSingleEmptyRun*/ )
{
if (pRedlineData)
{
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index fa9c170..f32a038 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -55,7 +55,7 @@ public:
/// Start of the text run.
///
- virtual void StartRun( const SwRedlineData* pRedlineData );
+ virtual void StartRun( const SwRedlineData* pRedlineData, bool bSingleEmptyRun = false );
/// End of the text run.
///
commit bbbb10a0774b9da546557632cd09c4f6958f8939
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Thu Jun 21 15:02:47 2012 +0200
n#758883 oox: anchor vml shapes without anchor info as at-character
w10:wrap was originally arrived to
writerfilter::dmapper::WrapHandler::lcl_attribute(), but
writerfilter::dmapper::DomainMapper_Impl::PushShapeContext() was called
already and set the anchor type. Fix this, then we can set a a suitable
anchor type in lcl_SetAnchorType() based on the type model.
Change-Id: Ib411450b10f29f814bc13d81eaec434971b2e52a
diff --git a/oox/inc/oox/vml/vmlshape.hxx b/oox/inc/oox/vml/vmlshape.hxx
index b9e4908..1e49743 100644
--- a/oox/inc/oox/vml/vmlshape.hxx
+++ b/oox/inc/oox/vml/vmlshape.hxx
@@ -92,6 +92,8 @@ struct ShapeTypeModel
OptValue< ::rtl::OUString > moGraphicPath; ///< Path to a graphic for this shape.
OptValue< ::rtl::OUString > moGraphicTitle; ///< Title of the graphic.
+ OptValue< ::rtl::OUString > moWrapAnchorX; ///< The base object from which our horizontal positioning should be calculated.
+ OptValue< ::rtl::OUString > moWrapAnchorY; ///< The base object from which our vertical positioning should be calculated.
explicit ShapeTypeModel();
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 4f0f952..3637385 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -385,10 +385,16 @@ void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
{
if ( rTypeModel.maPosition == "absolute" )
{
- // I'm not sure if AT_PAGE is always correct here (not sure what the parent that
- // the spec talks about can be), but with Writer SwXDrawPage::add()
- // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point.
- rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE);
+ if (rTypeModel.moWrapAnchorX.get() == "page" && rTypeModel.moWrapAnchorY.get() == "page")
+ {
+ // I'm not sure if AT_PAGE is always correct here (not sure what the parent that
+ // the spec talks about can be), but with Writer SwXDrawPage::add()
+ // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point.
+ rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE);
+ }
+ else
+ // Map to as-character by default, that fixes vertical position of some textframes.
+ rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_CHARACTER);
}
else if( rTypeModel.maPosition == "relative" )
{ // I'm not very sure this is correct either.
diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx
index 290a737..98e759d 100644
--- a/oox/source/vml/vmlshapecontext.cxx
+++ b/oox/source/vml/vmlshapecontext.cxx
@@ -322,11 +322,18 @@ ContextHandlerRef ShapeTypeContext::onCreateContext( sal_Int32 nElement, const A
mrTypeModel.maFillModel.moRotate = lclDecodeBool( rAttribs, XML_rotate );
break;
case VML_TOKEN( imagedata ):
+ {
// shapes in docx use r:id for the relationship id
// in xlsx it they use o:relid
bool bHasORelId = rAttribs.hasAttribute( O_TOKEN( relid ) );
mrTypeModel.moGraphicPath = decodeFragmentPath( rAttribs, bHasORelId ? O_TOKEN( relid ) : R_TOKEN( id ) );
mrTypeModel.moGraphicTitle = rAttribs.getString( O_TOKEN( title ) );
+ }
+ break;
+ case NMSP_vmlWord | XML_wrap:
+ mrTypeModel.moWrapAnchorX = rAttribs.getString(XML_anchorx);
+ mrTypeModel.moWrapAnchorY = rAttribs.getString(XML_anchory);
+ break;
break;
}
return 0;
diff --git a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
index 0724c65..6efa44c 100644
--- a/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
+++ b/writerfilter/source/ooxml/OOXMLFastContextHandler.cxx
@@ -2241,7 +2241,12 @@ OOXMLFastContextHandlerWrapper::lcl_createFastChildContext
bool bInNamespaces = mMyNamespaces.find(nNameSpace) != mMyNamespaces.end();
bool bInTokens = mMyTokens.find( Element ) != mMyTokens.end( );
- if ( bInNamespaces )
+
+ // We have methods to _add_ individual tokens or whole namespaces to be
+ // processed by writerfilter (instead of oox), but we have no method to
+ // filter out a single token. Just hardwire the wrap token here till we
+ // need a more generic solution.
+ if ( bInNamespaces && Element != static_cast<sal_Int32>(NS_vml_wordprocessingDrawing | OOXML_wrap) )
xResult.set(OOXMLFactory::getInstance()->createFastChildContextFromStart(this, Element));
else if (mxContext.is())
{
commit 7db67719ef00466f626bfa59ae7bb27ec7a19fd9
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jun 20 15:41:57 2012 +0200
oox: mso-wrap-style is about wrapping mode for text in shapes
This commit partially reverts 9e8957de203bb9abb208516ad32aee9527feb67b
(as it interpreted mso-wrap-style as the wrap type of the textbox
itself, not the wrap type of the contained text) and also extends the
effect of commit 0016757efef898205452a586ba5927e5d11fdabe to the
SimpleShape class as well.
Conflicts:
oox/source/vml/vmlshape.cxx
Change-Id: If2bded6ad94f2866e8ea398ff0f2792e8c8e86b0
diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx
index 44fc631..4f0f952 100644
--- a/oox/source/vml/vmlshape.cxx
+++ b/oox/source/vml/vmlshape.cxx
@@ -381,6 +381,25 @@ SimpleShape::SimpleShape( Drawing& rDrawing, const OUString& rService ) :
{
}
+void lcl_SetAnchorType(PropertySet& rPropSet, const ShapeTypeModel& rTypeModel)
+{
+ if ( rTypeModel.maPosition == "absolute" )
+ {
+ // I'm not sure if AT_PAGE is always correct here (not sure what the parent that
+ // the spec talks about can be), but with Writer SwXDrawPage::add()
+ // always in practice uses this because of pDoc->GetCurrentLayout() being NULL at this point.
+ rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PAGE);
+ }
+ else if( rTypeModel.maPosition == "relative" )
+ { // I'm not very sure this is correct either.
+ rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AT_PARAGRAPH);
+ }
+ else // static (is the default) means anchored inline
+ {
+ rPropSet.setProperty(PROP_AnchorType, text::TextContentAnchorType_AS_CHARACTER);
+ }
+}
+
Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const Rectangle& rShapeRect ) const
{
Rectangle aShapeRect(rShapeRect);
@@ -417,17 +436,16 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes
PropertySet( xShape ).setProperty( PROP_LegacyFragment, xInStrm );
}
+ PropertySet aPropertySet(xShape);
if (xShape.is() && !maTypeModel.maRotation.isEmpty())
{
- PropertySet aPropertySet(xShape);
aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(maTypeModel.maRotation.toInt32() * 100));
// If rotation is used, simple setPosition() is not enough.
aPropertySet.setAnyProperty(PROP_HoriOrientPosition, makeAny( aShapeRect.X ) );
aPropertySet.setAnyProperty(PROP_VertOrientPosition, makeAny( aShapeRect.Y ) );
}
- if (xShape.is() && maTypeModel.maWrapStyle == "none")
- PropertySet(xShape).setAnyProperty(PROP_AnchorType, makeAny(text::TextContentAnchorType_AS_CHARACTER));
+ lcl_SetAnchorType(aPropertySet, maTypeModel);
return xShape;
}
@@ -612,6 +630,9 @@ Reference< XShape > ComplexShape::implConvertAndInsert( const Reference< XShapes
aPropSet.setProperty(PROP_VertOrientPosition, rShapeRect.Y);
aPropSet.setProperty(PROP_Opaque, sal_False);
}
+
+ lcl_SetAnchorType(aPropSet, maTypeModel);
+
if ( maTypeModel.maPositionVerticalRelative == "page" )
{
aPropSet.setProperty(PROP_VertOrientRelation, text::RelOrientation::PAGE_FRAME);
commit 6b199a3eef9faa2b9c7cb03c6e06679e203329d8
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Wed Jun 20 12:46:45 2012 +0200
n#758883 dmapper: set wrap mode even if determining the position failed
Change-Id: I514828469e68f2ae88309418e64ee93be30455f3
diff --git a/writerfilter/source/dmapper/OLEHandler.cxx b/writerfilter/source/dmapper/OLEHandler.cxx
index 9ef3364..495d25b 100644
--- a/writerfilter/source/dmapper/OLEHandler.cxx
+++ b/writerfilter/source/dmapper/OLEHandler.cxx
@@ -108,24 +108,30 @@ void OLEHandler::lcl_attribute(Id rName, Value & rVal)
if( xTempShape.is() )
{
m_xShape.set( xTempShape );
+ uno::Reference< beans::XPropertySet > xShapeProps( xTempShape, uno::UNO_QUERY );
+ PropertyNameSupplier& rNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
try
{
m_aShapeSize = xTempShape->getSize();
m_aShapePosition = xTempShape->getPosition();
- uno::Reference< beans::XPropertySet > xShapeProps( xTempShape, uno::UNO_QUERY_THROW );
- PropertyNameSupplier& rNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
-
xShapeProps->getPropertyValue( rNameSupplier.GetName( PROP_BITMAP ) ) >>= m_xReplacement;
+ }
+ catch( const uno::Exception& e )
+ {
+ SAL_WARN("writerfilter", "Exception in OLE Handler: " << e.Message);
+ }
+ try
+ {
xShapeProps->setPropertyValue(
rNameSupplier.GetName( PROP_SURROUND ),
uno::makeAny( m_nWrapMode ) );
}
catch( const uno::Exception& e )
{
- SAL_WARN("writerfilter", "Exception in OLE Handler: " << e.Message);
+ SAL_WARN("writerfilter", "Exception while setting wrap mode: " << e.Message);
}
}
}
commit 18c20cbee35062539e2d03a89d1e1b806578a79d
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jun 19 17:36:28 2012 +0200
n#758883 DomainMapper::lcl_startParagraphGroup: set style name consistently
Change-Id: I71c3ebfcb68a53a291bcab2fdd397d62fd8b368a
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index d4b01d6..f51ce3f 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -3223,7 +3223,10 @@ void DomainMapper::lcl_startParagraphGroup()
if (m_pImpl->GetTopContext())
{
if (!m_pImpl->IsInShape())
+ {
m_pImpl->GetTopContext()->Insert( PROP_PARA_STYLE_NAME, true, uno::makeAny( sDefault ) );
+ m_pImpl->SetCurrentParaStyleId(sDefault);
+ }
if (m_pImpl->isBreakDeferred(PAGE_BREAK))
m_pImpl->GetTopContext()->Insert( PROP_BREAK_TYPE, true, uno::makeAny( com::sun::star::style::BreakType_PAGE_BEFORE) );
else if (m_pImpl->isBreakDeferred(COLUMN_BREAK))
commit 26f4a898aaaf123ec12407412dd7b27fa5e18f07
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jun 19 16:10:52 2012 +0200
n#758883 dmapper: take care of border width when setting margins
Word handles the "border to page" distance as a subset of the page
margin. Writer handles these values separately, and the real margin is
the sum of the border width, the margin and the border width itself.
The problem was that the width of the border itself wasn't counted, so
the real margin was a bit larger than necessary.
Change-Id: Id38153308f1e321b6556762b30f3377f2360edf6
diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx
index 58dd2b4..913eaac 100644
--- a/writerfilter/source/dmapper/PropertyMap.cxx
+++ b/writerfilter/source/dmapper/PropertyMap.cxx
@@ -501,17 +501,20 @@ void SectionPropertyMap::ApplyBorderToPageStyles(
}
if( m_nBorderDistances[nBorder] >= 0 )
{
+ sal_uInt32 nLineWidth = 0;
+ if (m_pBorderLines[nBorder])
+ nLineWidth = m_pBorderLines[nBorder]->LineWidth;
SetBorderDistance( xFirst, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
- m_nBorderDistances[nBorder], nOffsetFrom );
+ m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth );
if(xSecond.is())
SetBorderDistance( xSecond, aMarginIds[nBorder], aBorderDistanceIds[nBorder],
- m_nBorderDistances[nBorder], nOffsetFrom );
+ m_nBorderDistances[nBorder], nOffsetFrom, nLineWidth );
}
}
}
void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet > xStyle,
- PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom )
+ PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth )
{
PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
@@ -523,8 +526,8 @@ void SectionPropertyMap::SetBorderDistance( uno::Reference< beans::XPropertySet
sal_Int32 nMargin = 0;
aMargin >>= nMargin;
- // Change the margins with the border distance
- xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance ) );
+ // Change the margins with the ( border distance - line width )
+ xStyle->setPropertyValue( sMarginName, uno::makeAny( nDistance - nLineWidth ) );
// Set the distance to ( Margin - distance )
nDist = nMargin - nDistance;
diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx
index ba5e1ab..b9a3d5d 100644
--- a/writerfilter/source/dmapper/PropertyMap.hxx
+++ b/writerfilter/source/dmapper/PropertyMap.hxx
@@ -207,7 +207,7 @@ class SectionPropertyMap : public PropertyMap
bool HasFooter( bool bFirstPage ) const;
void SetBorderDistance( ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > xStyle,
- PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom );
+ PropertyIds eMarginId, PropertyIds eDistId, sal_Int32 nDistance, sal_Int32 nOffsetFrom, sal_uInt32 nLineWidth );
public:
explicit SectionPropertyMap(bool bIsFirstSection);
commit 7a9c9567b2431b6b1c4c8cf0aa0565ae2def63da
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jun 19 09:28:28 2012 +0100
n#758883 dmapper: paragraph-level run props should affect numberings as well
Change-Id: I707105f6da53a6cb790d743738875acde561e20f
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index c3b8a10..d4b01d6 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1437,6 +1437,7 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
Value::Pointer_t pValue = rSprm.getValue();
sal_Int32 nIntValue = pValue->getInt();
rtl::OUString sStringValue = pValue->getString();
+ PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier();
switch(nSprmId)
{
@@ -1983,6 +1984,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
rContext->Insert(ePropertyId, true, aBold );
if( nSprmId != NS_sprm::LN_CFBoldBi ) // sprmCFBoldBi
rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, true, aBold );
+
+ uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
+ if (xCharStyle.is())
+ xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_WEIGHT), aBold);
}
break;
case 61: /*sprmCFItalic*/
@@ -2060,6 +2065,10 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
//Asian get the same value as Western
rContext->Insert( PROP_CHAR_HEIGHT, true, aVal );
rContext->Insert( PROP_CHAR_HEIGHT_ASIAN, true, aVal );
+
+ uno::Reference<beans::XPropertySet> xCharStyle(m_pImpl->GetCurrentNumberingCharStyle());
+ if (xCharStyle.is())
+ xCharStyle->setPropertyValue(rPropNameSupplier.GetName(PROP_CHAR_HEIGHT), aVal);
}
}
break;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
index 165fd2f..13abcad 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx
@@ -3585,6 +3585,48 @@ void DomainMapper_Impl::ApplySettingsTable()
}
}
+uno::Reference<beans::XPropertySet> DomainMapper_Impl::GetCurrentNumberingCharStyle()
+{
+ uno::Reference<beans::XPropertySet> xRet;
+ OUString aStyle = GetCurrentParaStyleId();
+ if (aStyle.isEmpty() || GetTopContextType() != CONTEXT_PARAGRAPH)
+ return xRet;
+ const StyleSheetEntryPtr pEntry = GetStyleSheetTable()->FindStyleSheetByISTD(aStyle);
+ if (!pEntry)
+ return xRet;
+ const StyleSheetPropertyMap* pStyleSheetProperties = dynamic_cast<const StyleSheetPropertyMap*>(pEntry ? pEntry->pProperties.get() : 0);
+ sal_Int32 nListId = pStyleSheetProperties->GetListId();
+ sal_Int32 nListLevel = pStyleSheetProperties->GetListLevel();
+ if (nListId < 0 || nListLevel < 0)
+ return xRet;
+
+ // So we are in a paragraph style and it has numbering. Look up the relevant character style.
+ OUString aListName = ListDef::GetStyleName(nListId);
+ uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier(GetTextDocument(), uno::UNO_QUERY);
+ uno::Reference< container::XNameAccess > xStyleFamilies = xStylesSupplier->getStyleFamilies();
+ uno::Reference<container::XNameAccess> xNumberingStyles;
+ xStyleFamilies->getByName("NumberingStyles") >>= xNumberingStyles;
+ uno::Reference<beans::XPropertySet> xStyle(xNumberingStyles->getByName(aListName), uno::UNO_QUERY);
+ uno::Reference<container::XIndexAccess> xLevels(xStyle->getPropertyValue("NumberingRules"), uno::UNO_QUERY);
+ uno::Sequence<beans::PropertyValue> aProps;
+ xLevels->getByIndex(nListLevel) >>= aProps;
+ for (int i = 0; i < aProps.getLength(); ++i)
+ {
+ const beans::PropertyValue& rProp = aProps[i];
+
+ if (rProp.Name == "CharStyleName")
+ {
+ OUString aCharStyle;
+ rProp.Value >>= aCharStyle;
+ uno::Reference<container::XNameAccess> xCharacterStyles;
+ xStyleFamilies->getByName("CharacterStyles") >>= xCharacterStyles;
+ xRet.set(xCharacterStyles->getByName(aCharStyle), uno::UNO_QUERY);
+ break;
+ }
+ }
+ return xRet;
+}
+
SectionPropertyMap * DomainMapper_Impl::GetSectionContext()
{
SectionPropertyMap* pSectionContext = 0;
diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
index 07f6934..77a2b62 100644
--- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx
+++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx
@@ -613,6 +613,8 @@ public:
void ApplySettingsTable();
SectionPropertyMap * GetSectionContext();
+ /// If the current paragraph has a numbering style associated, this method returns its character style
+ com::sun::star::uno::Reference<com::sun::star::beans::XPropertySet> GetCurrentNumberingCharStyle();
};
} //namespace dmapper
} //namespace writerfilter
commit e9350744611464eaf7fd673958c02cfec621f737
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Jun 19 09:28:06 2012 +0100
n#758883 dmapper: always set list id during stylesheet import
This way the sprm handlers can be aware that a numbering is provided by
that style.
Change-Id: I5b5f1570a9e50fd8b3372f5ac7a6cd48e9751254
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx
index 9f3d115..c3b8a10 100644
--- a/writerfilter/source/dmapper/DomainMapper.cxx
+++ b/writerfilter/source/dmapper/DomainMapper.cxx
@@ -1484,15 +1484,15 @@ void DomainMapper::sprmWithProps( Sprm& rSprm, PropertyMapPtr rContext, SprmType
//convert the ListTable entry to a NumberingRules propery and apply it
ListsManager::Pointer pListTable = m_pImpl->GetListTable();
ListDef::Pointer pList = pListTable->GetList( nIntValue );
+ if( m_pImpl->IsStyleSheetImport() )
+ {
+ //style sheets cannot have a numbering rule attached
+ StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
+ pStyleSheetPropertyMap->SetListId( nIntValue );
+ }
if( pList.get( ) )
{
- if( m_pImpl->IsStyleSheetImport() )
- {
- //style sheets cannot have a numbering rule attached
- StyleSheetPropertyMap* pStyleSheetPropertyMap = dynamic_cast< StyleSheetPropertyMap* >( rContext.get() );
- pStyleSheetPropertyMap->SetListId( nIntValue );
- }
- else
+ if( !m_pImpl->IsStyleSheetImport() )
{
uno::Any aRules = uno::makeAny( pList->GetNumberingRules( ) );
rContext->Insert( PROP_NUMBERING_RULES, true, aRules );
More information about the Libreoffice-commits
mailing list