[Libreoffice-commits] core.git: 8 commits - writerfilter/source
Miklos Vajna
vmiklos at suse.cz
Tue Apr 9 22:32:53 PDT 2013
writerfilter/source/rtftok/rtfdocumentimpl.cxx | 35 +++------
writerfilter/source/rtftok/rtfsdrimport.cxx | 90 ++++++++++++++++++++++---
writerfilter/source/rtftok/rtfsdrimport.hxx | 2
3 files changed, 94 insertions(+), 33 deletions(-)
New commits:
commit eb9475b940450761ae5196b2a7635d1dfeaebb5f
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 17:53:13 2013 +0200
RTF equivalent of 229f6e187bd85d0af47da9feffef2d9ac7f83120
Change-Id: I18165df2a2a59d460b06b0cfd3fcdae977bc65ee
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index f5f53b2..6d296a4 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -179,7 +179,11 @@ void RTFSdrImport::resolve(RTFShape& rShape)
else if (i->first == "fillColor" && xPropertySet.is())
{
aAny <<= msfilter::util::BGRToRGB(i->second.toInt32());
- xPropertySet->setPropertyValue("FillColor", aAny);
+ if (bTextFrame)
+ xPropertySet->setPropertyValue("BackColor", aAny);
+ else
+ xPropertySet->setPropertyValue("FillColor", aAny);
+ xPropertySet->setPropertyValue("BackColorTransparency", uno::makeAny(sal_Int32(0)));
}
else if ( i->first == "fillBackColor" )
; // Ignore: complementer of fillColor
commit b51519bfd1c4643a7ce74e4b3934281460027703
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 17:17:33 2013 +0200
RTF: also import rectangles as Writer text frames
Change-Id: I5aae8cbc050187b1adf7757b112470a8e9e6160e
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index bbb6dd6..f5f53b2 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -144,9 +144,10 @@ void RTFSdrImport::resolve(RTFShape& rShape)
nType = i->second.toInt32();
switch (nType)
{
- case 20: // Line
+ case ESCHER_ShpInst_Line:
createShape("com.sun.star.drawing.LineShape", xShape, xPropertySet);
break;
+ case ESCHER_ShpInst_Rectangle:
case ESCHER_ShpInst_TextBox:
{
createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
@@ -346,9 +347,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
else if (i->first == "dyWrapDistBottom")
xPropertySet->setPropertyValue("BottomMargin", uno::makeAny(i->second.toInt32() / 360));
else
- SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle shape property '" <<
- OUStringToOString( i->first, RTL_TEXTENCODING_UTF8 ).getStr() << "':'" <<
- OUStringToOString( i->second, RTL_TEXTENCODING_UTF8 ).getStr() << "'");
+ SAL_INFO("writerfilter", "TODO handle shape property '" << i->first << "':'" << i->second << "'");
}
if (xPropertySet.is())
commit e789c7f0f15a6b571de95b81e77e3a323e9f540e
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 16:52:23 2013 +0200
RTF import of d{x,y}WrapDist* shape properties
Change-Id: Id59c8dd91de2733cf0f3620d7b27e8a34f3034fc
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 8bd8ef5..bbb6dd6 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -337,6 +337,14 @@ void RTFSdrImport::resolve(RTFShape& rShape)
xPropertySet->setPropertyValue("RightBorderDistance", uno::makeAny(i->second.toInt32() / 360));
else if (i->first == "dyTextBottom")
xPropertySet->setPropertyValue("BottomBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dxWrapDistLeft")
+ xPropertySet->setPropertyValue("LeftMargin", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dyWrapDistTop")
+ xPropertySet->setPropertyValue("TopMargin", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dxWrapDistRight")
+ xPropertySet->setPropertyValue("RightMargin", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dyWrapDistBottom")
+ xPropertySet->setPropertyValue("BottomMargin", uno::makeAny(i->second.toInt32() / 360));
else
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle shape property '" <<
OUStringToOString( i->first, RTL_TEXTENCODING_UTF8 ).getStr() << "':'" <<
commit c8988c87728f5331a8374d97f8849a47026cd2f1
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 16:32:18 2013 +0200
fix RTF import of default fFitShapeToText
Change-Id: I7813ea4b3a2cb97c334bca04e6ff556690725b5f
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 56e1618..8bd8ef5 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -33,6 +33,7 @@
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/SizeType.hpp>
#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/WritingMode.hpp>
@@ -95,6 +96,9 @@ std::vector<beans::PropertyValue> RTFSdrImport::getTextFrameDefaults()
aPropertyValue.Name = "BottomBorderDistance";
aPropertyValue.Value <<= sal_Int32(0);
aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "SizeType";
+ aPropertyValue.Value <<= text::SizeType::FIX;
+ aRet.push_back(aPropertyValue);
return aRet;
}
commit 5c706a48ba834f4d573950664bacde5076b1579e
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 16:27:17 2013 +0200
RTF import of d{x,y}Text* shape properties
Change-Id: I6ce85cc4fd7bb317be002f5aa7295a03f0d0e7dd
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 5fdfeb4..56e1618 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -324,6 +324,15 @@ void RTFSdrImport::resolve(RTFShape& rShape)
aViewBox.Height = i->second.toInt32();
else if ( i->first == "dhgt" )
resolveDhgt(xPropertySet, i->second.toInt32());
+ // These are in EMU, convert to mm100.
+ else if (i->first == "dxTextLeft")
+ xPropertySet->setPropertyValue("LeftBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dyTextTop")
+ xPropertySet->setPropertyValue("TopBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dxTextRight")
+ xPropertySet->setPropertyValue("RightBorderDistance", uno::makeAny(i->second.toInt32() / 360));
+ else if (i->first == "dyTextBottom")
+ xPropertySet->setPropertyValue("BottomBorderDistance", uno::makeAny(i->second.toInt32() / 360));
else
SAL_INFO("writerfilter", OSL_THIS_FUNC << ": TODO handle shape property '" <<
OUStringToOString( i->first, RTL_TEXTENCODING_UTF8 ).getStr() << "':'" <<
commit 7c50826d9a233499277da83fd57bafd834262ec6
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 16:07:05 2013 +0200
RTF import of new-style frames: fix defaults
Change-Id: I0b674f770f467a32dc2fa5bb7227f038addae4a8
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 231ccef..b458bff 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -2551,29 +2551,9 @@ int RTFDocumentImpl::dispatchFlag(RTFKeyword nKeyword)
case RTF_DPTXBX:
{
m_aStates.top().aDrawingObject.xShape.set(getModelFactory()->createInstance("com.sun.star.text.TextFrame"), uno::UNO_QUERY);
- // These are the default in Word, but not in Writer
- beans::PropertyValue aPropertyValue;
- aPropertyValue.Name = "HoriOrient";
- aPropertyValue.Value <<= text::HoriOrientation::NONE;
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
- aPropertyValue.Name = "VertOrient";
- aPropertyValue.Value <<= text::VertOrientation::NONE;
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
- aPropertyValue.Name = "BackColorTransparency";
- aPropertyValue.Value <<= sal_Int32(100);
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
- aPropertyValue.Name = "LeftBorderDistance";
- aPropertyValue.Value <<= sal_Int32(0);
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
- aPropertyValue.Name = "RightBorderDistance";
- aPropertyValue.Value <<= sal_Int32(0);
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
- aPropertyValue.Name = "TopBorderDistance";
- aPropertyValue.Value <<= sal_Int32(0);
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
- aPropertyValue.Name = "BottomBorderDistance";
- aPropertyValue.Value <<= sal_Int32(0);
- m_aStates.top().aDrawingObject.aPendingProperties.push_back(aPropertyValue);
+ std::vector<beans::PropertyValue> aDefaults = m_pSdrImport->getTextFrameDefaults();
+ for (size_t i = 0; i < aDefaults.size(); ++i)
+ m_aStates.top().aDrawingObject.aPendingProperties.push_back(aDefaults[i]);
}
break;
default:
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index 0363f73..5fdfeb4 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -32,6 +32,8 @@
#include <com/sun/star/drawing/EnhancedCustomShapeSegment.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeParameterPair.hpp>
#include <com/sun/star/drawing/EnhancedCustomShapeSegmentCommand.hpp>
+#include <com/sun/star/text/HoriOrientation.hpp>
+#include <com/sun/star/text/VertOrientation.hpp>
#include <com/sun/star/text/WrapTextMode.hpp>
#include <com/sun/star/text/WritingMode.hpp>
@@ -67,6 +69,35 @@ void RTFSdrImport::createShape(OUString aStr, uno::Reference<drawing::XShape>& x
xPropertySet.set(xShape, uno::UNO_QUERY);
}
+std::vector<beans::PropertyValue> RTFSdrImport::getTextFrameDefaults()
+{
+ std::vector<beans::PropertyValue> aRet;
+ beans::PropertyValue aPropertyValue;
+
+ aPropertyValue.Name = "HoriOrient";
+ aPropertyValue.Value <<= text::HoriOrientation::NONE;
+ aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "VertOrient";
+ aPropertyValue.Value <<= text::VertOrientation::NONE;
+ aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "BackColorTransparency";
+ aPropertyValue.Value <<= sal_Int32(100);
+ aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "LeftBorderDistance";
+ aPropertyValue.Value <<= sal_Int32(0);
+ aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "RightBorderDistance";
+ aPropertyValue.Value <<= sal_Int32(0);
+ aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "TopBorderDistance";
+ aPropertyValue.Value <<= sal_Int32(0);
+ aRet.push_back(aPropertyValue);
+ aPropertyValue.Name = "BottomBorderDistance";
+ aPropertyValue.Value <<= sal_Int32(0);
+ aRet.push_back(aPropertyValue);
+ return aRet;
+}
+
void RTFSdrImport::resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder)
{
writerfilter::dmapper::DomainMapper& rMapper = (writerfilter::dmapper::DomainMapper&)m_rImport.Mapper();
@@ -113,8 +144,13 @@ void RTFSdrImport::resolve(RTFShape& rShape)
createShape("com.sun.star.drawing.LineShape", xShape, xPropertySet);
break;
case ESCHER_ShpInst_TextBox:
- createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
- bTextFrame = true;
+ {
+ createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
+ bTextFrame = true;
+ std::vector<beans::PropertyValue> aDefaults = getTextFrameDefaults();
+ for (size_t j = 0; j < aDefaults.size(); ++j)
+ xPropertySet->setPropertyValue(aDefaults[j].Name, aDefaults[j].Value);
+ }
break;
default:
bCustom = true;
diff --git a/writerfilter/source/rtftok/rtfsdrimport.hxx b/writerfilter/source/rtftok/rtfsdrimport.hxx
index a508f77..6c39fbc 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.hxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.hxx
@@ -43,6 +43,8 @@ namespace writerfilter {
void resolve(RTFShape& rShape);
void resolveDhgt(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nZOrder);
void resolveFLine(uno::Reference<beans::XPropertySet> xPropertySet, sal_Int32 nFLine);
+ /// These are the default in Word, but not in Writer.
+ std::vector<beans::PropertyValue> getTextFrameDefaults();
private:
void createShape(OUString aService, uno::Reference<drawing::XShape>& xShape, uno::Reference<beans::XPropertySet>& xPropertySet);
commit 7e2a3812ce98942be43ba1be4a4695e9adcf988d
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 15:42:26 2013 +0200
RTF import of new-style frames: avoid fake empty paragraph at the end
Change-Id: I0abd941fbebfc032a3f3827929cfa721a187852e
diff --git a/writerfilter/source/rtftok/rtfdocumentimpl.cxx b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
index 102c0ba..231ccef 100644
--- a/writerfilter/source/rtftok/rtfdocumentimpl.cxx
+++ b/writerfilter/source/rtftok/rtfdocumentimpl.cxx
@@ -1164,6 +1164,7 @@ void RTFDocumentImpl::text(OUString& rString)
void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer)
{
+ bool bShapeText = !m_aShapetextBuffer.empty();
while (rBuffer.size())
{
std::pair<RTFBufferTypes, RTFValue::Pointer_t> aPair = rBuffer.front();
@@ -1201,7 +1202,13 @@ void RTFDocumentImpl::replayBuffer(RTFBuffer_t& rBuffer)
else if (aPair.first == BUFFER_ENDRUN)
Mapper().endCharacterGroup();
else if (aPair.first == BUFFER_PAR)
- parBreak();
+ {
+ if (!rBuffer.empty() || !bShapeText)
+ // RTF may have a fake paragraph at the end of the shape text,
+ // that would cause an additional empty paragraph at the end of
+ // the shape text.
+ parBreak();
+ }
else
SAL_WARN("writerfilter", "should not happen");
}
commit 4984bf2a870a1fb7d1f85b1f6ece568a0e05c4cb
Author: Miklos Vajna <vmiklos at suse.cz>
Date: Tue Apr 9 15:32:34 2013 +0200
RTF filter: import text box shapes as a Writer textframe
Text box shapes, just like any other shape types, used to be imported as
drawinglayer shapes. To keep the DOC/DOCX/RTF filters in sync, import
text box shapes as Writer textframes instead.
Change-Id: Iacead5352d0a297cff54afb134d895e40d446147
diff --git a/writerfilter/source/rtftok/rtfsdrimport.cxx b/writerfilter/source/rtftok/rtfsdrimport.cxx
index b7d0e19..0363f73 100644
--- a/writerfilter/source/rtftok/rtfsdrimport.cxx
+++ b/writerfilter/source/rtftok/rtfsdrimport.cxx
@@ -86,6 +86,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
int nType = -1;
bool bPib = false;
bool bCustom = false;
+ bool bTextFrame = false;
uno::Reference<drawing::XShape> xShape;
uno::Reference<beans::XPropertySet> xPropertySet;
@@ -111,6 +112,10 @@ void RTFSdrImport::resolve(RTFShape& rShape)
case 20: // Line
createShape("com.sun.star.drawing.LineShape", xShape, xPropertySet);
break;
+ case ESCHER_ShpInst_TextBox:
+ createShape("com.sun.star.text.TextFrame", xShape, xPropertySet);
+ bTextFrame = true;
+ break;
default:
bCustom = true;
break;
@@ -118,7 +123,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
// Defaults
aAny <<= (sal_uInt32)0xffffff; // White in Word, kind of blue in Writer.
- if (xPropertySet.is())
+ if (xPropertySet.is() && !bTextFrame)
xPropertySet->setPropertyValue("FillColor", aAny);
}
else if ( i->first == "wzName" )
@@ -291,7 +296,8 @@ void RTFSdrImport::resolve(RTFShape& rShape)
if (xPropertySet.is())
{
- xPropertySet->setPropertyValue("LineColor", aLineColor);
+ if (!bTextFrame)
+ xPropertySet->setPropertyValue("LineColor", aLineColor);
xPropertySet->setPropertyValue("LineWidth", aLineWidth);
if (rShape.oZ)
resolveDhgt(xPropertySet, *rShape.oZ);
@@ -304,7 +310,7 @@ void RTFSdrImport::resolve(RTFShape& rShape)
return;
}
- if (m_xDrawPage.is())
+ if (m_xDrawPage.is() && !bTextFrame)
m_xDrawPage->add(xShape);
if (bCustom && xShape.is())
{
@@ -344,7 +350,13 @@ void RTFSdrImport::resolve(RTFShape& rShape)
// Set position and size
if (xShape.is())
{
- xShape->setPosition(awt::Point(rShape.nLeft, rShape.nTop));
+ if (bTextFrame)
+ {
+ xPropertySet->setPropertyValue("HoriOrientPosition", uno::makeAny(rShape.nLeft));
+ xPropertySet->setPropertyValue("VertOrientPosition", uno::makeAny(rShape.nTop));
+ }
+ else
+ xShape->setPosition(awt::Point(rShape.nLeft, rShape.nTop));
xShape->setSize(awt::Size(rShape.nRight - rShape.nLeft, rShape.nBottom - rShape.nTop));
if (rShape.nHoriOrientRelation != 0)
xPropertySet->setPropertyValue("HoriOrientRelation", uno::makeAny(rShape.nHoriOrientRelation));
More information about the Libreoffice-commits
mailing list