[Libreoffice-commits] core.git: sw/inc sw/qa sw/source
Justin Luth
justin_luth at sil.org
Sat Oct 17 06:51:14 PDT 2015
sw/inc/pagedesc.hxx | 7 ++
sw/qa/extras/ww8export/data/tdf36117_verticalAdjustment.doc |binary
sw/qa/extras/ww8export/ww8export.cxx | 27 ++++++++
sw/source/core/layout/pagedesc.cxx | 5 -
sw/source/filter/ww8/attributeoutputbase.hxx | 6 +
sw/source/filter/ww8/wrtw8sty.cxx | 28 ++++++++
sw/source/filter/ww8/ww8attributeoutput.hxx | 3
sw/source/filter/ww8/ww8par.cxx | 2
sw/source/filter/ww8/ww8par.hxx | 6 +
sw/source/filter/ww8/ww8par2.cxx | 8 ++
sw/source/filter/ww8/ww8par6.cxx | 40 ++++++++++--
11 files changed, 125 insertions(+), 7 deletions(-)
New commits:
commit fbd1c167851a04c60d91daa830cf93e5b2ad7b4d
Author: Justin Luth <justin_luth at sil.org>
Date: Mon Sep 7 08:19:22 2015 +0300
tdf#36117 .doc preserve page vertical alignment after RT
MSWord has a page-style vertical alignment (center/bottom/justify)
setting that was lost after round-tripping through LibreOffice.
Writer does not currently have the ability to vertically align text
outside of a frame, but the setting should be preserved for
interoperability.
Change-Id: I91ae841b91ca2f2dd1b68212fdcdf830c7cef22a
Reviewed-on: https://gerrit.libreoffice.org/18480
Tested-by: Jenkins <ci at libreoffice.org>
Reviewed-by: Justin Luth <justin_luth at sil.org>
diff --git a/sw/inc/pagedesc.hxx b/sw/inc/pagedesc.hxx
index b258ec1..258f634 100644
--- a/sw/inc/pagedesc.hxx
+++ b/sw/inc/pagedesc.hxx
@@ -26,6 +26,9 @@
#include <frmfmt.hxx>
#include <editeng/numitem.hxx>
#include <editeng/borderline.hxx>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
+
+using namespace ::com::sun::star;
class SfxPoolItem;
class SwTextFormatColl;
@@ -143,6 +146,7 @@ class SW_DLLPUBLIC SwPageDesc : public SwModify
SwPageDesc *m_pFollow;
sal_uInt16 m_nRegHeight; ///< Sentence spacing and fontascent of style.
sal_uInt16 m_nRegAscent; ///< For grid alignment (Registerhaltigkeit).
+ drawing::TextVerticalAdjust m_nVerticalAdjustment; // doc/docx: vertically center / justify / bottom
UseOnPage m_eUse;
bool m_IsLandscape;
bool m_IsHidden;
@@ -216,6 +220,9 @@ public:
void SetRegHeight(sal_uInt16 const nNew) { m_nRegHeight = nNew; }
void SetRegAscent(sal_uInt16 const nNew) { m_nRegAscent = nNew; }
+ drawing::TextVerticalAdjust GetVerticalAdjustment () const {return m_nVerticalAdjustment; }
+ void SetVerticalAdjustment (const drawing::TextVerticalAdjust nVA) {m_nVerticalAdjustment = nVA; }
+
inline void SetFollow( const SwPageDesc* pNew );
const SwPageDesc* GetFollow() const { return m_pFollow; }
SwPageDesc* GetFollow() { return m_pFollow; }
diff --git a/sw/qa/extras/ww8export/data/tdf36117_verticalAdjustment.doc b/sw/qa/extras/ww8export/data/tdf36117_verticalAdjustment.doc
new file mode 100644
index 0000000..f7afd41
Binary files /dev/null and b/sw/qa/extras/ww8export/data/tdf36117_verticalAdjustment.doc differ
diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx
index 6c9b007..6a54c5d 100644
--- a/sw/qa/extras/ww8export/ww8export.cxx
+++ b/sw/qa/extras/ww8export/ww8export.cxx
@@ -11,6 +11,7 @@
#include <com/sun/star/form/validation/XValidatableFormComponent.hpp>
#include <com/sun/star/frame/XStorable.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <com/sun/star/drawing/XControlShape.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/view/XViewSettingsSupplier.hpp>
@@ -19,6 +20,7 @@
#include <com/sun/star/text/GraphicCrop.hpp>
#include <com/sun/star/text/XFormField.hpp>
#include <com/sun/star/view/DocumentZoomType.hpp>
+#include <pagedesc.hxx>
#include <sfx2/bindings.hxx>
#include <sfx2/request.hxx>
@@ -498,6 +500,31 @@ DECLARE_WW8EXPORT_TEST(testCommentedTable, "commented-table.doc")
CPPUNIT_ASSERT_EQUAL(OUString("fore." SAL_NEWLINE_STRING "A1" SAL_NEWLINE_STRING "B1" SAL_NEWLINE_STRING "Afte"), xField->getAnchor()->getString());
}
+DECLARE_WW8EXPORT_TEST(testTextVerticalAdjustment, "tdf36117_verticalAdjustment.doc")
+{
+ //Preserve the page vertical alignment setting for .doc
+ SwXTextDocument* pTextDoc = dynamic_cast<SwXTextDocument *>(mxComponent.get());
+ CPPUNIT_ASSERT(pTextDoc);
+ SwDoc* pDoc = pTextDoc->GetDocShell()->GetDoc();
+ CPPUNIT_ASSERT(pDoc);
+
+ SwPageDesc &Desc = pDoc->GetPageDesc( 0 );
+ drawing::TextVerticalAdjust nVA = Desc.GetVerticalAdjustment();
+ CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_CENTER, nVA );
+
+ Desc = pDoc->GetPageDesc( 1 );
+ nVA = Desc.GetVerticalAdjustment();
+ CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_TOP, nVA );
+
+ Desc = pDoc->GetPageDesc( 2 );
+ nVA = Desc.GetVerticalAdjustment();
+ CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_BOTTOM, nVA );
+
+ Desc = pTextDoc->GetDocShell()->GetDoc()->GetPageDesc( 3 );
+ nVA = Desc.GetVerticalAdjustment();
+ CPPUNIT_ASSERT_EQUAL( drawing::TextVerticalAdjust_BLOCK, nVA );
+}
+
DECLARE_WW8EXPORT_TEST(testCommentExport, "comment-export.odt")
{
struct TextPortionInfo {
diff --git a/sw/source/core/layout/pagedesc.cxx b/sw/source/core/layout/pagedesc.cxx
index aa53e36..a236b1c 100644
--- a/sw/source/core/layout/pagedesc.cxx
+++ b/sw/source/core/layout/pagedesc.cxx
@@ -36,8 +36,6 @@
#include <poolfmt.hxx>
#include <calbck.hxx>
-using namespace ::com::sun::star;
-
SwPageDesc::SwPageDesc(const OUString& rName, SwFrameFormat *pFormat, SwDoc *const pDoc)
: SwModify(nullptr)
, m_StyleName( rName )
@@ -49,6 +47,7 @@ SwPageDesc::SwPageDesc(const OUString& rName, SwFrameFormat *pFormat, SwDoc *con
, m_pFollow( this )
, m_nRegHeight( 0 )
, m_nRegAscent( 0 )
+ , m_nVerticalAdjustment( drawing::TextVerticalAdjust_TOP )
, m_eUse( (UseOnPage)(nsUseOnPage::PD_ALL | nsUseOnPage::PD_HEADERSHARE | nsUseOnPage::PD_FOOTERSHARE | nsUseOnPage::PD_FIRSTSHARE) )
, m_IsLandscape( false )
, m_IsHidden( false )
@@ -67,6 +66,7 @@ SwPageDesc::SwPageDesc( const SwPageDesc &rCpy )
, m_pFollow( rCpy.m_pFollow )
, m_nRegHeight( rCpy.GetRegHeight() )
, m_nRegAscent( rCpy.GetRegAscent() )
+ , m_nVerticalAdjustment( rCpy.GetVerticalAdjustment() )
, m_eUse( rCpy.ReadUseOn() )
, m_IsLandscape( rCpy.GetLandscape() )
, m_IsHidden( rCpy.IsHidden() )
@@ -90,6 +90,7 @@ SwPageDesc & SwPageDesc::operator = (const SwPageDesc & rSrc)
m_nRegHeight = rSrc.m_nRegHeight;
m_nRegAscent = rSrc.m_nRegAscent;
+ m_nVerticalAdjustment = rSrc.m_nVerticalAdjustment;
m_eUse = rSrc.m_eUse;
m_IsLandscape = rSrc.m_IsLandscape;
return *this;
diff --git a/sw/source/filter/ww8/attributeoutputbase.hxx b/sw/source/filter/ww8/attributeoutputbase.hxx
index a180564..fd36534 100644
--- a/sw/source/filter/ww8/attributeoutputbase.hxx
+++ b/sw/source/filter/ww8/attributeoutputbase.hxx
@@ -29,6 +29,7 @@
#include <tools/solar.h>
#include <boost/optional.hpp>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <swtypes.hxx>
#include <wrtswtbl.hxx>
#include <fldbas.hxx>
@@ -36,6 +37,8 @@
#include <vector>
+using namespace ::com::sun::star;
+
class Point;
class SvxCaseMapItem;
class SvxColorItem;
@@ -293,6 +296,9 @@ public:
/// msword::ColumnBreak or msword::PageBreak
virtual void SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectionInfo = NULL ) = 0;
+ // preserve page vertical alignment
+ virtual void TextVerticalAdjustment( const drawing::TextVerticalAdjust) {};
+
/// Start of the section properties.
virtual void StartSection() = 0;
diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx
index b102aea..1e710a6 100644
--- a/sw/source/filter/ww8/wrtw8sty.cxx
+++ b/sw/source/filter/ww8/wrtw8sty.cxx
@@ -1440,6 +1440,30 @@ void WW8Export::SetupSectionPositions( WW8_PdAttrDesc* pA )
}
}
+void WW8AttributeOutput::TextVerticalAdjustment( const drawing::TextVerticalAdjust nVA )
+{
+ if ( drawing::TextVerticalAdjust_TOP != nVA ) // top alignment is the default
+ {
+ sal_uInt8 nMSVA = 0;
+ switch( nVA )
+ {
+ case drawing::TextVerticalAdjust_CENTER:
+ nMSVA = 1;
+ break;
+ case drawing::TextVerticalAdjust_BOTTOM: //Writer = 2, Word = 3
+ nMSVA = 3;
+ break;
+ case drawing::TextVerticalAdjust_BLOCK: //Writer = 3, Word = 2
+ nMSVA = 2;
+ break;
+ default:
+ break;
+ }
+ SwWW8Writer::InsUInt16( *m_rWW8Export.pO, NS_sprm::LN_SVjc );
+ m_rWW8Export.pO->push_back( nMSVA );
+ }
+}
+
void WW8Export::WriteHeadersFooters( sal_uInt8 nHeadFootFlags,
const SwFrameFormat& rFormat, const SwFrameFormat& rLeftFormat, const SwFrameFormat& rFirstPageFormat, sal_uInt8 nBreakCode )
{
@@ -1666,6 +1690,10 @@ void MSWordExportBase::SectionProperties( const WW8_SepInfo& rSepInfo, WW8_PdAtt
AttrOutput().SectionType( nBreakCode );
+ if( rSepInfo.pPageDesc ) {
+ AttrOutput().TextVerticalAdjustment( rSepInfo.pPageDesc->GetVerticalAdjustment() );
+ }
+
// Header or Footer
sal_uInt8 nHeadFootFlags = 0;
diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx
index 294686e..59f183f 100644
--- a/sw/source/filter/ww8/ww8attributeoutput.hxx
+++ b/sw/source/filter/ww8/ww8attributeoutput.hxx
@@ -147,6 +147,9 @@ public:
/// msword::ColumnBreak or msword::PageBreak
virtual void SectionBreak( sal_uInt8 nC, const WW8_SepInfo* pSectionInfo = NULL ) override;
+ // preserve DOC page vertical alignment
+ virtual void TextVerticalAdjustment( const drawing::TextVerticalAdjust ) SAL_OVERRIDE;
+
/// Start of the section properties.
virtual void StartSection() override;
diff --git a/sw/source/filter/ww8/ww8par.cxx b/sw/source/filter/ww8/ww8par.cxx
index f2f5dbe..2d4e710 100644
--- a/sw/source/filter/ww8/ww8par.cxx
+++ b/sw/source/filter/ww8/ww8par.cxx
@@ -4327,6 +4327,8 @@ void wwSectionManager::SetSegmentToPageDesc(const wwSection &rSection,
GetPageULData(rSection, aULData);
SetPageULSpaceItems(rFormat, aULData, rSection);
+ rPage.SetVerticalAdjustment( rSection.mnVerticalAdjustment );
+
SetPage(rPage, rFormat, rSection, bIgnoreCols);
if (!(rSection.maSep.pgbApplyTo & 1))
diff --git a/sw/source/filter/ww8/ww8par.hxx b/sw/source/filter/ww8/ww8par.hxx
index 64fb6cc..1f6933c 100644
--- a/sw/source/filter/ww8/ww8par.hxx
+++ b/sw/source/filter/ww8/ww8par.hxx
@@ -45,6 +45,7 @@
#include <xmloff/odffields.hxx>
#include <IMark.hxx>
+#include <com/sun/star/drawing/TextVerticalAdjust.hpp>
#include <swtypes.hxx>
#include <fmtfsize.hxx>
#include <fmtornt.hxx>
@@ -55,6 +56,8 @@
#include <boost/noncopyable.hpp>
+using namespace ::com::sun::star;
+
class SwDoc;
class SwPaM;
class SfxPoolItem;
@@ -810,6 +813,7 @@ public:
sal_uInt32 nPgLeft;
sal_uInt32 nPgRight;
+ drawing::TextVerticalAdjust mnVerticalAdjustment;
sal_uInt8 mnBorders;
bool mbHasFootnote;
void SetDirection();
@@ -896,6 +900,7 @@ public:
explicit wwSectionManager(SwWW8ImplReader &rReader) : mrReader(rReader), mnDesc(0)
{}
void SetCurrentSectionHasFootnote();
+ void SetCurrentSectionVerticalAdjustment(const drawing::TextVerticalAdjust nVA);
bool CurrentSectionIsVertical() const;
bool CurrentSectionIsProtected() const;
void PrependedInlineNode(const SwPosition &rPos, const SwNode &rNode);
@@ -1817,6 +1822,7 @@ public: // really private, but can only be done public
void Read_ParaBiDi(sal_uInt16, const sal_uInt8* pData, short nLen);
static sal_uInt32 ExtractColour(const sal_uInt8* &rpData, bool bVer67);
+ void Read_TextVerticalAdjustment(sal_uInt16, const sal_uInt8* pData, short nLen);
void Read_UnderlineColor(sal_uInt16, const sal_uInt8* pData, short nLen);
long MapBookmarkVariables(const WW8FieldDesc* pF, OUString &rOrigName,
const OUString &rData);
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 757d14b..233cc11 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -224,6 +224,14 @@ void wwSectionManager::SetCurrentSectionHasFootnote()
maSegments.back().mbHasFootnote = true;
}
+void wwSectionManager::SetCurrentSectionVerticalAdjustment(const drawing::TextVerticalAdjust nVA)
+{
+ OSL_ENSURE(!maSegments.empty(),
+ "should not be possible, must be at least one segment");
+ if ( !maSegments.empty() )
+ maSegments.back().mnVerticalAdjustment = nVA;
+}
+
bool wwSectionManager::CurrentSectionIsVertical() const
{
OSL_ENSURE(!maSegments.empty(),
diff --git a/sw/source/filter/ww8/ww8par6.cxx b/sw/source/filter/ww8/ww8par6.cxx
index 2077882..85b2fc6 100644
--- a/sw/source/filter/ww8/ww8par6.cxx
+++ b/sw/source/filter/ww8/ww8par6.cxx
@@ -754,10 +754,17 @@ void SwWW8ImplReader::HandleLineNumbering(const wwSection &rSection)
}
}
-wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.nNode),
- mpSection(0), mpPage(0), meDir(FRMDIR_HORI_LEFT_TOP), mLinkId(0),
- nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width()),
- nPgLeft(MM_250), nPgRight(MM_250), mnBorders(0), mbHasFootnote(false)
+wwSection::wwSection(const SwPosition &rPos) : maStart(rPos.nNode)
+ , mpSection(0)
+ , mpPage(0)
+ , meDir(FRMDIR_HORI_LEFT_TOP)
+ , mLinkId(0)
+ , nPgWidth(SvxPaperInfo::GetPaperSize(PAPER_A4).Width())
+ , nPgLeft(MM_250)
+ , nPgRight(MM_250)
+ , mnVerticalAdjustment(drawing::TextVerticalAdjust_TOP)
+ , mnBorders(0)
+ , mbHasFootnote(false)
{
}
@@ -4707,6 +4714,29 @@ sal_uInt32 SwWW8ImplReader::ExtractColour(const sal_uInt8* &rpData, bool bVer67)
return aShade.aColor.GetColor();
}
+void SwWW8ImplReader::Read_TextVerticalAdjustment( sal_uInt16, const sal_uInt8* pData, short nLen )
+{
+ if( nLen > 0 )
+ {
+ drawing::TextVerticalAdjust nVA = drawing::TextVerticalAdjust_TOP;
+ switch( *pData )
+ {
+ case 1:
+ nVA = drawing::TextVerticalAdjust_CENTER;
+ break;
+ case 2: //justify
+ nVA = drawing::TextVerticalAdjust_BLOCK;
+ break;
+ case 3:
+ nVA = drawing::TextVerticalAdjust_BOTTOM;
+ break;
+ default:
+ break;
+ }
+ m_aSectionManager.SetCurrentSectionVerticalAdjustment( nVA );
+ }
+}
+
void SwWW8ImplReader::Read_Border(sal_uInt16 , const sal_uInt8*, short nLen)
{
if( nLen < 0 )
@@ -5983,7 +6013,7 @@ const wwSprmDispatcher *GetWW8SprmDispatcher()
//sep.dyaHdrBottom;dya;word;
{0x3019, 0}, //"sprmSLBetween"
//sep.fLBetween;0 or 1;byte;
- {0x301A, 0}, //"sprmSVjc" sep.vjc;vjc;byte;
+ {0x301A, &SwWW8ImplReader::Read_TextVerticalAdjustment}, //"sprmSVjc" sep.vjc;vjc;byte;
{0x501B, 0}, //"sprmSLnnMin" sep.lnnMin;lnn;
//word;
{0x501C, 0}, //"sprmSPgnStart" sep.pgnStart;
More information about the Libreoffice-commits
mailing list