Kaydet (Commit) 4a1888a9 authored tarafından Luboš Luňák's avatar Luboš Luňák

fix reading a .doc that has frame anchored to the end of page (bnc#787942)

MSWord, unlike Writer, can anchor even to a page break (i.e. after the last
paragraph). When this document was read, what happended was:
- the last paragraph was read and the current position PaM was set to point
  after it
- frame was read and anchored to the PaM
- page break was read, making everything following be moved to the next page;
  including whatever ended up at the PaM position
Handle this by checking for this case and inserting an extra empty paragraph
before the break. This shouldn't affect layout of the page itself anyway,
since the break should leave room for it (and MSWord shows a page break
there if control characters are enabled, so there is room).

Change-Id: Ia2a13bf5cf1c959b5aa228254365019a00a22679
üst 1bc19605
This diff was suppressed by a .gitattributes entry.
...@@ -504,6 +504,13 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section- ...@@ -504,6 +504,13 @@ DECLARE_WW8IMPORT_TEST(testFloatingTableSectionColumns, "floating-table-section-
CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 ); CPPUNIT_ASSERT( tableWidth.toInt32() > 10000 );
} }
DECLARE_WW8IMPORT_TEST(testBnc787942, "bnc787942.doc")
{
// The frame ended up on the second page instead of first.
parseDump("/root/page[1]/body/txt[4]/anchored");
}
CPPUNIT_PLUGIN_IMPLEMENT(); CPPUNIT_PLUGIN_IMPLEMENT();
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -1383,6 +1383,8 @@ private: ...@@ -1383,6 +1383,8 @@ private:
// a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field() // a document position recorded the after-position of TOC section, managed by Read_F_TOX() and End_Field()
SwPaM* mpPosAfterTOC; SwPaM* mpPosAfterTOC;
boost::scoped_ptr< SwPosition > lastAnchorPos;
bool mbCareFirstParaEndInToc; bool mbCareFirstParaEndInToc;
bool mbCareLastParaEndInToc; bool mbCareLastParaEndInToc;
cp_set maTOXEndCps; cp_set maTOXEndCps;
......
...@@ -795,6 +795,18 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/) ...@@ -795,6 +795,18 @@ void wwSectionManager::CreateSep(const long nTxtPos, bool /*bMustHaveBreak*/)
if (!pSep) if (!pSep)
return; return;
if (!maSegments.empty() && mrReader.lastAnchorPos.get() && *mrReader.lastAnchorPos == *mrReader.pPaM->GetPoint())
{
bool insert = true;
SwPaM pam( *mrReader.lastAnchorPos );
if( pam.Move(fnMoveBackward, fnGoNode))
if( SwTxtNode* txtNode = pam.GetPoint()->nNode.GetNode().GetTxtNode())
if( txtNode->Len() == 0 )
insert = false;
if( insert )
mrReader.AppendTxtNode(*mrReader.pPaM->GetPoint());
}
ww::WordVersion eVer = mrReader.GetFib().GetFIBVersion(); ww::WordVersion eVer = mrReader.GetFib().GetFIBVersion();
// M.M. Create a linked section if the WkbPLCF // M.M. Create a linked section if the WkbPLCF
...@@ -1736,7 +1748,6 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM, ...@@ -1736,7 +1748,6 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
const sal_Int32 nIniFlyDx, const sal_Int32 nIniFlyDx,
const sal_Int32 nIniFlyDy ) const sal_Int32 nIniFlyDy )
{ {
(void) rPaM;
(void) nPgLeft; (void) nPgLeft;
memset( this, 0, sizeof( WW8SwFlyPara ) ); // Initialisieren memset( this, 0, sizeof( WW8SwFlyPara ) ); // Initialisieren
...@@ -1804,6 +1815,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM, ...@@ -1804,6 +1815,7 @@ WW8SwFlyPara::WW8SwFlyPara( SwPaM& rPaM,
//#i53725# - absolute positioned objects have to be //#i53725# - absolute positioned objects have to be
// anchored at-paragraph to assure its correct anchor position. // anchored at-paragraph to assure its correct anchor position.
eAnchor = FLY_AT_PARA; eAnchor = FLY_AT_PARA;
rIo.lastAnchorPos.reset( new SwPosition(*rPaM.GetPoint()));
switch (nYBind) switch (nYBind)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment