Hi, I have submitted a patch for review:
https://gerrit.libreoffice.org/4240 To pull it, you can do: git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/40/4240/1 fdo#36791 : fix for import of greeting card Change-Id: Id9d68e3e5bc2e2335ef1d1b3a8605a0de64ae8ea --- M editeng/source/editeng/editeng.cxx M editeng/source/outliner/outliner.cxx M include/editeng/editeng.hxx M include/editeng/outliner.hxx M include/oox/vml/vmltextbox.hxx M oox/source/vml/vmlshape.cxx M oox/source/vml/vmlshapecontext.cxx M oox/source/vml/vmltextbox.cxx M oox/source/vml/vmltextboxcontext.cxx M svx/source/customshapes/EnhancedCustomShape2d.cxx M svx/source/svdraw/svdmodel.cxx M svx/source/svdraw/svdograf.cxx M svx/source/svdraw/svdotextdecomposition.cxx M svx/source/unodraw/unoshap2.cxx M sw/qa/extras/ooxmlimport/ooxmlimport.cxx M sw/source/core/layout/fly.cxx M sw/source/filter/ww8/docxattributeoutput.cxx 17 files changed, 190 insertions(+), 14 deletions(-) diff --git a/editeng/source/editeng/editeng.cxx b/editeng/source/editeng/editeng.cxx index 9bf29e5..7aa5cf1 100644 --- a/editeng/source/editeng/editeng.cxx +++ b/editeng/source/editeng/editeng.cxx @@ -102,6 +102,7 @@ { DBG_CTOR( EditEngine, 0 ); pImpEditEngine = new ImpEditEngine( this, pItemPool ); + mpStripRec = new Rectangle(); } EditEngine::~EditEngine() @@ -1879,12 +1880,34 @@ { DBG_CHKTHIS( EditEngine, 0 ); VirtualDevice aTmpDev; +#if 0 // Modify for greeting.docx error. Rectangle aBigRect( Point( 0, 0 ), Size( 0x7FFFFFFF, 0x7FFFFFFF ) ); if ( IsVertical() ) { aBigRect.Right() = 0; aBigRect.Left() = -0x7FFFFFFF; } +#endif + // Set Clipping area + Rectangle aBigRect; + + GetStripArea(aBigRect); + sal_uInt32 rectHeight = aBigRect.GetHeight(); + + sal_uInt16 nParaNum = GetParagraphCount(); + sal_uInt32 nHeight = 0; + sal_uInt32 nLastHeight = 0; + for(int i = 0; i < nParaNum; i ++) + { + nLastHeight = GetTextHeight( i ); + nHeight += nLastHeight; + if (nHeight >= rectHeight) + break; + } + + aBigRect.Top() = 0; + aBigRect.Bottom() = (rectHeight - nLastHeight); + pImpEditEngine->Paint( &aTmpDev, aBigRect, Point(), sal_True ); } @@ -2936,11 +2959,21 @@ return pImpEditEngine->InsertLineBreak(rEditSelection); } +void EditEngine::SetStripArea( const Rectangle& rRect ) +{ + (*mpStripRec) = rRect; +} + +void EditEngine::GetStripArea( Rectangle& rRect ) +{ + rRect = (*mpStripRec); +} + + EFieldInfo::EFieldInfo() { pFieldItem = NULL; } - EFieldInfo::EFieldInfo( const SvxFieldItem& rFieldItem, sal_Int32 nPara, sal_uInt16 nPos ) : aPosition( nPara, nPos ) { diff --git a/editeng/source/outliner/outliner.cxx b/editeng/source/outliner/outliner.cxx index db6915d..895bbfa 100644 --- a/editeng/source/outliner/outliner.cxx +++ b/editeng/source/outliner/outliner.cxx @@ -1335,6 +1335,7 @@ bBlockInsCallback = sal_False; nMaxDepth = 9; + mStripRec = Rectangle(); pParaList = new ParagraphList; pParaList->SetVisibleStateChangedHdl( LINK( this, Outliner, ParaVisibleStateChangedHdl ) ); @@ -1784,6 +1785,7 @@ { DBG_CHKTHIS(Outliner,0); bStrippingPortions = sal_True; + pEditEngine->SetStripArea(GetStripArea()); pEditEngine->StripPortions(); bStrippingPortions = sal_False; } diff --git a/include/editeng/editeng.hxx b/include/editeng/editeng.hxx index a3ba78d..d71043d 100644 --- a/include/editeng/editeng.hxx +++ b/include/editeng/editeng.hxx @@ -129,6 +129,7 @@ private: ImpEditEngine* pImpEditEngine; + Rectangle* mpStripRec; EDITENG_DLLPRIVATE EditEngine( const EditEngine& ); EDITENG_DLLPRIVATE EditEngine& operator=( const EditEngine& ); @@ -579,6 +580,9 @@ bool Undo(EditView* pView); bool Redo(EditView* pView); + + virtual void SetStripArea( const Rectangle& rRect ); + virtual void GetStripArea( Rectangle& rRect ); }; #endif // _MyEDITENG_HXX diff --git a/include/editeng/outliner.hxx b/include/editeng/outliner.hxx index c9c0b0b..7f2f1ba 100644 --- a/include/editeng/outliner.hxx +++ b/include/editeng/outliner.hxx @@ -633,6 +633,8 @@ sal_uLong nDummy; + Rectangle mStripRec; + DECL_LINK( ParaVisibleStateChangedHdl, Paragraph* ); DECL_LINK( BeginMovingParagraphsHdl, void* ); DECL_LINK( EndMovingParagraphsHdl, MoveParagraphsInfo* ); @@ -1040,6 +1042,9 @@ // convenient method to determine the bullets/numbering status for all paragraphs sal_Int32 GetBulletsNumberingStatus() const; + + void SetStripArea( const Rectangle& rRect ) { mStripRec = rRect; } + Rectangle GetStripArea() const { return mStripRec; }; }; #endif diff --git a/include/oox/vml/vmltextbox.hxx b/include/oox/vml/vmltextbox.hxx index 4975e6b..3643855 100644 --- a/include/oox/vml/vmltextbox.hxx +++ b/include/oox/vml/vmltextbox.hxx @@ -59,8 +59,9 @@ { TextFontModel maFont; OUString maText; + OUString maJc; - explicit TextPortionModel( const TextFontModel& rFont, const OUString& rText ); + explicit TextPortionModel( const TextFontModel& rFont, const OUString& rText, const OUString& rJc ); }; // ============================================================================ @@ -73,6 +74,12 @@ /** Appends a new text portion to the textbox. */ void appendPortion( const TextFontModel& rFont, const OUString& rText ); + + /** Appends LINE_BREAK to last text portion . */ + void appendLineBreak(); + + /** Set TextPortionModel`s justify. */ + void setJustify(const OUString& rText); /** Returns the current number of text portions. */ inline size_t getPortionCount() const { return maPortions.size(); } @@ -92,6 +99,7 @@ typedef ::std::vector< TextPortionModel > PortionVector; PortionVector maPortions; + OUString maJc; }; // ============================================================================ diff --git a/oox/source/vml/vmlshape.cxx b/oox/source/vml/vmlshape.cxx index 35ad93d..5156357 100644 --- a/oox/source/vml/vmlshape.cxx +++ b/oox/source/vml/vmlshape.cxx @@ -481,6 +481,7 @@ Reference< XShape > SimpleShape::implConvertAndInsert( const Reference< XShapes >& rxShapes, const awt::Rectangle& rShapeRect ) const { awt::Rectangle aShapeRect(rShapeRect); + bool bFlipX = false, bFlipY = false; boost::optional<sal_Int32> oRotation; if (!maTypeModel.maRotation.isEmpty()) oRotation.reset(maTypeModel.maRotation.toInt32()); @@ -492,15 +493,18 @@ aShapeRect.Width *= -1; if (oRotation) oRotation.reset(360 - *oRotation); + bFlipX = true; } else if (maTypeModel.maFlip.equalsAscii("y")) { aShapeRect.Y += aShapeRect.Height; aShapeRect.Height *= -1; + bFlipY = true; } } Reference< XShape > xShape = mrDrawing.createAndInsertXShape( maService, rxShapes, aShapeRect ); + PropertySet( xShape ).setProperty( PROP_TextAutoGrowHeight, false); convertShapeProperties( xShape ); if ( maService.equalsAscii( "com.sun.star.text.TextFrame" ) ) @@ -558,7 +562,7 @@ } PropertySet aPropertySet(xShape); - if (xShape.is() && oRotation) + /* if (xShape.is() && oRotation) { // See DffPropertyReader::Fix16ToAngle(): in VML, positive rotation angles are clockwise, we have them as counter-clockwise. // Additionally, VML type is 0..360, our is 0.36000. @@ -566,6 +570,23 @@ // 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() && (oRotation || bFlipX || bFlipY)) + { + if (oRotation) + { + // See DffPropertyReader::Fix16ToAngle(): in VML, positive rotation angles are clockwise, we have them as counter-clockwise. + // Additionally, VML type is 0..360, our is 0.36000. + aPropertySet.setAnyProperty(PROP_RotateAngle, makeAny(sal_Int32(NormAngle360((*oRotation) * -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 (bFlipX) + aPropertySet.setAnyProperty(PROP_MirroredX, makeAny( bFlipX ) ); + if (bFlipY) + aPropertySet.setAnyProperty(PROP_MirroredY, makeAny( bFlipY ) ); + aPropertySet.setAnyProperty(PROP_CustomShapeGeometry, makeAny( true ) ); } lcl_SetAnchorType(aPropertySet, maTypeModel); diff --git a/oox/source/vml/vmlshapecontext.cxx b/oox/source/vml/vmlshapecontext.cxx index efa6e38..8b2f14d 100644 --- a/oox/source/vml/vmlshapecontext.cxx +++ b/oox/source/vml/vmlshapecontext.cxx @@ -246,9 +246,26 @@ return new GroupShapeContext( rParent, rShapes.createShape< GroupShape >(), rAttribs ); case VML_TOKEN( shape ): if (rAttribs.hasAttribute(XML_path)) - return new ShapeContext( rParent, rShapes.createShape< BezierShape >(), rAttribs ); + { + bool bBezier = false; + const OUString path = rAttribs.getXString( XML_path, OUString() ); + for ( sal_Int32 i = 0; i < path.getLength(); i++ ) + { + if (path[i] == 'c') + { + bBezier = true; + break; + } + } + if (bBezier) + return new ShapeContext( rParent, rShapes.createShape< BezierShape >(), rAttribs ); + else + return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs ); + } else + { return new ShapeContext( rParent, rShapes.createShape< ComplexShape >(), rAttribs ); + } case VML_TOKEN( rect ): return new RectangleShapeContext( rParent, rAttribs, rShapes.createShape< RectangleShape >() ); case VML_TOKEN( roundrect ): diff --git a/oox/source/vml/vmltextbox.cxx b/oox/source/vml/vmltextbox.cxx index 1499091..0146d48 100644 --- a/oox/source/vml/vmltextbox.cxx +++ b/oox/source/vml/vmltextbox.cxx @@ -24,6 +24,7 @@ #include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/text/XTextAppend.hpp> #include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/text/ControlCharacter.hpp> namespace oox { namespace vml { @@ -34,9 +35,10 @@ { } -TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& rText ) : +TextPortionModel::TextPortionModel( const TextFontModel& rFont, const OUString& rText, const OUString& rJc ) : maFont( rFont ), - maText( rText ) + maText( rText ), + maJc( rJc ) { } @@ -52,7 +54,20 @@ void TextBox::appendPortion( const TextFontModel& rFont, const OUString& rText ) { - maPortions.push_back( TextPortionModel( rFont, rText ) ); + maPortions.push_back( TextPortionModel( rFont, rText, maJc ) ); +} + +void TextBox::appendLineBreak() +{ + if (getPortionCount() <= 0) + return; + + maPortions.push_back( TextPortionModel( maPortions.back().maFont, OUString("\x0A"), maJc ) ); +} + +void TextBox::setJustify(const OUString& rText) +{ + maJc = rText; } const TextFontModel* TextBox::getFirstFont() const @@ -88,6 +103,29 @@ aPropertyValue.Value = uno::makeAny(double(rFont.monSize.get()) / 2.); aPropVec.push_back(aPropertyValue); } + + if (rFont.moName.has()) + { + aPropertyValue.Name = "CharFontName"; + aPropertyValue.Value = uno::makeAny(rFont.moName.get()); + aPropVec.push_back(aPropertyValue); + } + if (!aIt->maJc.isEmpty()) + { + sal_Int16 adj = 0; // left - SVX_ADJUST_LEFT + if (aIt->maJc == "right") // - SVX_ADJUST_RIGHT + adj = 1; + else if (aIt->maJc == "block") // - SVX_ADJUST_BLOCK + adj = 2; + else if (aIt->maJc == "center") // - SVX_ADJUST_CENTER + adj = 3; + else if (aIt->maJc == "blockline") // - SVX_ADJUST_BLOCKLINE + adj = 4; + aPropertyValue.Name = "ParaAdjust"; + aPropertyValue.Value = uno::makeAny(adj); + aPropVec.push_back(aPropertyValue); + } + uno::Sequence<beans::PropertyValue> aPropSeq(aPropVec.size()); beans::PropertyValue* pValues = aPropSeq.getArray(); for (std::vector<beans::PropertyValue>::iterator i = aPropVec.begin(); i != aPropVec.end(); ++i) diff --git a/oox/source/vml/vmltextboxcontext.cxx b/oox/source/vml/vmltextboxcontext.cxx index ca124bc..f135de0 100644 --- a/oox/source/vml/vmltextboxcontext.cxx +++ b/oox/source/vml/vmltextboxcontext.cxx @@ -125,6 +125,15 @@ case OOX_TOKEN(doc, sz): maFont.monSize = rAttribs.getInteger( OOX_TOKEN(doc, val) ); break; + case OOX_TOKEN(doc, rFonts): + maFont.moName = rAttribs.getString( OOX_TOKEN(doc, ascii) ); + break; + case OOX_TOKEN(doc, u): + maFont.monUnderline = rAttribs.getInteger( OOX_TOKEN(doc, val) ); + break; + case OOX_TOKEN(doc, i): + maFont.mobItalic = true; + break; } } @@ -203,10 +212,22 @@ if( nElement == XML_font ) return new TextPortionContext( *this, mrTextBox, TextFontModel(), nElement, rAttribs ); break; case OOX_TOKEN(doc, txbxContent): - if (nElement == OOX_TOKEN(doc, p)) return this; + if (nElement == OOX_TOKEN(doc, p)) + { + if (mrTextBox.getPortionCount() > 0) + mrTextBox.appendLineBreak(); + mrTextBox.setJustify(OUString("")); + + return this; + } break; case OOX_TOKEN(doc, p): if (nElement == OOX_TOKEN(doc, r)) return new TextPortionContext( *this, mrTextBox, TextFontModel(), nElement, rAttribs ); + if (nElement == OOX_TOKEN(doc, pPr)) return this; + break; + case OOX_TOKEN(doc, pPr): + if (nElement == OOX_TOKEN(doc, jc)) + mrTextBox.setJustify(rAttribs.getString( OOX_TOKEN(doc, val) ).get()); break; } return 0; diff --git a/svx/source/customshapes/EnhancedCustomShape2d.cxx b/svx/source/customshapes/EnhancedCustomShape2d.cxx index f17e145..8bce424 100644 --- a/svx/source/customshapes/EnhancedCustomShape2d.cxx +++ b/svx/source/customshapes/EnhancedCustomShape2d.cxx @@ -1434,6 +1434,14 @@ } } + // Make twice - this is wrong. + aRect.Left() -= aRect.GetWidth(); + aRect.Bottom() += aRect.GetHeight(); + aStart.X() -= (aRect.Right() - aStart.X()); + aStart.Y() += (aStart.Y() - aRect.Top()); + aEnd.X() -= (aRect.Right() - aEnd.X()); + aEnd.Y() += (aEnd.Y() - aRect.Top()); + Polygon aTempPoly( aRect, aStart, aEnd, POLY_ARC, bFullCircle ); basegfx::B2DPolygon aRetval; diff --git a/svx/source/svdraw/svdmodel.cxx b/svx/source/svdraw/svdmodel.cxx index a184de7..f55e693 100644 --- a/svx/source/svdraw/svdmodel.cxx +++ b/svx/source/svdraw/svdmodel.cxx @@ -195,7 +195,7 @@ else nDefTextHgt = SdrEngineDefaults::GetFontHeight(); - pItemPool->SetPoolDefaultItem( SdrTextWordWrapItem( sal_False ) ); + pItemPool->SetPoolDefaultItem( SdrTextWordWrapItem( sal_True ) ); SetTextDefaults(); pLayerAdmin=new SdrLayerAdmin; diff --git a/svx/source/svdraw/svdograf.cxx b/svx/source/svdraw/svdograf.cxx index c968809..5d63691 100644 --- a/svx/source/svdraw/svdograf.cxx +++ b/svx/source/svdraw/svdograf.cxx @@ -49,6 +49,7 @@ #include <svx/svdogrp.hxx> #include <svx/xbtmpit.hxx> #include <svx/xflbmtit.hxx> +#include <svx/xflclit.hxx> #include <svx/svdundo.hxx> #include "svdfmtf.hxx" #include <svx/sdgcpitm.hxx> @@ -977,7 +978,8 @@ } else { - SetMergedItem(XFillStyleItem(XFILL_NONE)); + SetMergedItem(XFillColorItem(String(), Color( COL_WHITE ))); + SetMergedItem(XFillStyleItem(XFILL_SOLID)); SetMergedItem(XLineStyleItem(XLINE_NONE)); } } diff --git a/svx/source/svdraw/svdotextdecomposition.cxx b/svx/source/svdraw/svdotextdecomposition.cxx index 0d53e44..a0291fd 100644 --- a/svx/source/svdraw/svdotextdecomposition.cxx +++ b/svx/source/svdraw/svdotextdecomposition.cxx @@ -1053,6 +1053,8 @@ aClipRange.expand(basegfx::B2DTuple(aAnchorTextSize.Width(), aAnchorTextSize.Height()) - aAdjOffset); } + rOutliner.SetStripArea(GetGeoRect()); + // now break up text primitives. impTextBreakupHandler aConverter(rOutliner); aConverter.decomposeBlockTextPrimitive(aNewTransformA, aNewTransformB, aClipRange); diff --git a/svx/source/unodraw/unoshap2.cxx b/svx/source/unodraw/unoshap2.cxx index e96f7e1..8b8dd83 100644 --- a/svx/source/unodraw/unoshap2.cxx +++ b/svx/source/unodraw/unoshap2.cxx @@ -1900,6 +1900,13 @@ bool bCustomShapeGeometry = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "CustomShapeGeometry" ) ); + sal_Bool bSetMirroredX = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MirroredX" ) ); + sal_Bool bSetMirroredY = pObject && aPropertyName.equalsAsciiL( RTL_CONSTASCII_STRINGPARAM( "MirroredY" ) ); + if (bSetMirroredX) + ((SdrObjCustomShape*)pObject)->SetMirroredX(true); + if (bSetMirroredY) + ((SdrObjCustomShape*)pObject)->SetMirroredY(true); + sal_Bool bMirroredX = sal_False; sal_Bool bMirroredY = sal_False; diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index c422ecc..69b69c4 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -357,7 +357,7 @@ uno::Reference<drawing::XDrawPage> xDrawPage = xDrawPageSupplier->getDrawPage(); uno::Reference<drawing::XShapes> xShapes(xDrawPage->getByIndex(1), uno::UNO_QUERY); uno::Reference<text::XTextRange> xShape(xShapes->getByIndex(0), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("TEXT1"), xShape->getString()); + CPPUNIT_ASSERT_EQUAL(OUString("TEXT1\n"), xShape->getString()); // we want to test the textbox is on the first page (it was put onto another page without the fix), // use a small trick and instead of checking the page layout, check the page style uno::Reference<text::XTextContent> xTextContent(xShape, uno::UNO_QUERY); diff --git a/sw/source/core/layout/fly.cxx b/sw/source/core/layout/fly.cxx index d921849..3fbc00e 100644 --- a/sw/source/core/layout/fly.cxx +++ b/sw/source/core/layout/fly.cxx @@ -453,9 +453,12 @@ SdrLayerID nHeavenId = pIDDMA->GetHeavenId(); SdrLayerID nHellId = pIDDMA->GetHellId(); // OD 2004-03-22 #i26791# + // At sw/source/core/basetyp/init.cxx:564, sw/source/core/unocore/unoframe.cxx:394, + // In case in document there has no opaque item, default set value. So a value will always exist. + // In case there is no opaque item, set layer to HellId. GetVirtDrawObj()->SetLayer( GetFmt()->GetOpaque().GetValue() - ? nHeavenId - : nHellId ); + ? nHellId + : nHeavenId ); if ( bNotify ) NotifyDrawObj(); } diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index a062499..4f09f10 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -4718,7 +4718,12 @@ OString sColor("#" + msfilter::util::ConvertColor(pTop->GetColor())); m_pFlyAttrList->add(XML_strokecolor, sColor); - double const fConverted(editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), pTop->GetWidth())); + double fConverted = 0; + if (pTop->GetBorderLineStyle() != com::sun::star::table::BorderLineStyle::NONE) + { + fConverted = editeng::ConvertBorderWidthToWord(pTop->GetBorderLineStyle(), pTop->GetWidth()); + } + sal_Int32 nWidth = sal_Int32(fConverted / 20); m_pFlyAttrList->add(XML_strokeweight, OString::valueOf(nWidth) + "pt"); } -- To view, visit https://gerrit.libreoffice.org/4240 To unsubscribe, visit https://gerrit.libreoffice.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Id9d68e3e5bc2e2335ef1d1b3a8605a0de64ae8ea Gerrit-PatchSet: 1 Gerrit-Project: core Gerrit-Branch: master Gerrit-Owner: Adam CloudOn <rattles2...@gmail.com> _______________________________________________ LibreOffice mailing list LibreOffice@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice