diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-01-03 15:21:32 +0100 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-01-06 02:15:48 +0100 |
commit | d3a5776b00ee07ac371dd180a6d962d50da4baf5 (patch) | |
tree | f8c03c02c9b25fa0974ef33cd28aa3b26bcdb3a4 | |
parent | cp#2013101510000026: fix doc export of comments initials (diff) | |
download | core-d3a5776b00ee07ac371dd180a6d962d50da4baf5.tar.gz core-d3a5776b00ee07ac371dd180a6d962d50da4baf5.zip |
cp#2013101510000026: doc export of commented text ranges
(cherry picked from commit 5969eec0e998804eba77338b17de90737e2acb43)
Conflicts:
sw/qa/extras/ww8export/ww8export.cxx
sw/qa/extras/ww8import/ww8import.cxx
sw/source/filter/ww8/wrtw8sty.cxx
sw/source/filter/ww8/ww8attributeoutput.hxx
(cherry picked from commit 765d89aa149e9afc78382e24bf7c86f70b1584ff)
Change-Id: I2d31da5d659edcbebc682d5604d2db24b5e341fb
-rw-r--r-- | sw/qa/extras/ww8export/data/fdo59530.doc | bin | 0 -> 9728 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8export/ww8export.cxx | 27 | ||||
-rwxr-xr-x | sw/qa/extras/ww8import/data/fdo59530.doc | bin | 22528 -> 0 bytes | |||
-rw-r--r-- | sw/qa/extras/ww8import/ww8import.cxx | 26 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtw8sty.cxx | 104 | ||||
-rw-r--r-- | sw/source/filter/ww8/wrtww8.hxx | 8 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8atr.cxx | 5 | ||||
-rw-r--r-- | sw/source/filter/ww8/ww8attributeoutput.hxx | 2 |
8 files changed, 139 insertions, 33 deletions
diff --git a/sw/qa/extras/ww8export/data/fdo59530.doc b/sw/qa/extras/ww8export/data/fdo59530.doc Binary files differnew file mode 100644 index 000000000000..60cfe840a787 --- /dev/null +++ b/sw/qa/extras/ww8export/data/fdo59530.doc diff --git a/sw/qa/extras/ww8export/ww8export.cxx b/sw/qa/extras/ww8export/ww8export.cxx index 0c2f7698b3c5..29e2df5e734f 100644 --- a/sw/qa/extras/ww8export/ww8export.cxx +++ b/sw/qa/extras/ww8export/ww8export.cxx @@ -26,6 +26,7 @@ public: void test56513(); void testNewPageStylesTable(); void testFdo42144(); + void testFdo59530(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -48,6 +49,7 @@ void Test::run() {"fdo56513.doc", &Test::test56513}, {"new-page-styles.doc", &Test::testNewPageStylesTable}, {"fdo42144.odt", &Test::testFdo42144}, + {"fdo59530.doc", &Test::testFdo59530}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -149,6 +151,31 @@ void Test::testFdo42144() CPPUNIT_ASSERT_EQUAL(false, bool(getProperty<sal_Bool>(xStyle, "FooterIsOn"))); } +void Test::testFdo59530() +{ + // See ooxmlexport's testFdo38244(). + // Test comment range feature. + 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<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); + uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); + xRunEnum->nextElement(); + uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType")); + xRunEnum->nextElement(); + xRunEnum->nextElement(); + xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType")); + + // Test initials. + uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); + uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); + uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); + xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY); + CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); +} + CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); diff --git a/sw/qa/extras/ww8import/data/fdo59530.doc b/sw/qa/extras/ww8import/data/fdo59530.doc Binary files differdeleted file mode 100755 index 4e41cb8ecef6..000000000000 --- a/sw/qa/extras/ww8import/data/fdo59530.doc +++ /dev/null diff --git a/sw/qa/extras/ww8import/ww8import.cxx b/sw/qa/extras/ww8import/ww8import.cxx index 50ef934eb0b1..3311563a5ec3 100644 --- a/sw/qa/extras/ww8import/ww8import.cxx +++ b/sw/qa/extras/ww8import/ww8import.cxx @@ -30,7 +30,6 @@ public: void testN757118(); void testN757905(); void testAllGapsWord(); - void testFdo59530(); void testI120158(); void testN816603(); void testN816593(); @@ -57,7 +56,6 @@ void Test::run() {"n757118.doc", &Test::testN757118}, {"n757905.doc", &Test::testN757905}, {"all_gaps_word.doc", &Test::testAllGapsWord}, - {"fdo59530.doc", &Test::testFdo59530}, {"i120158.doc", &Test::testI120158}, {"n816603.doc", &Test::testN816603}, {"n816593.doc", &Test::testN816593}, @@ -221,30 +219,6 @@ void Test::testAllGapsWord() borderTest.testTheBorders(mxComponent); } -void Test::testFdo59530() -{ - // See ooxmlexport's testFdo38244(). - // Test comment range feature. - 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<container::XEnumerationAccess> xRunEnumAccess(xParaEnum->nextElement(), uno::UNO_QUERY); - uno::Reference<container::XEnumeration> xRunEnum = xRunEnumAccess->createEnumeration(); - xRunEnum->nextElement(); - uno::Reference<beans::XPropertySet> xPropertySet(xRunEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("TextFieldStart"), getProperty<OUString>(xPropertySet, "TextPortionType")); - xRunEnum->nextElement(); - xPropertySet.set(xRunEnum->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("TextFieldEnd"), getProperty<OUString>(xPropertySet, "TextPortionType")); - - // Test initials. - uno::Reference<text::XTextFieldsSupplier> xTextFieldsSupplier(mxComponent, uno::UNO_QUERY); - uno::Reference<container::XEnumerationAccess> xFieldsAccess(xTextFieldsSupplier->getTextFields()); - uno::Reference<container::XEnumeration> xFields(xFieldsAccess->createEnumeration()); - xPropertySet.set(xFields->nextElement(), uno::UNO_QUERY); - CPPUNIT_ASSERT_EQUAL(OUString("M"), getProperty<OUString>(xPropertySet, "Initials")); -} - void Test::testI120158() { // See https://issues.apache.org/ooo/show_bug.cgi?id=120158 diff --git a/sw/source/filter/ww8/wrtw8sty.cxx b/sw/source/filter/ww8/wrtw8sty.cxx index 17aad68abb78..0b5422cb8ceb 100644 --- a/sw/source/filter/ww8/wrtw8sty.cxx +++ b/sw/source/filter/ww8/wrtw8sty.cxx @@ -1945,9 +1945,11 @@ void WW8_WrPlcFtnEdn::Append( WW8_CP nCp, const SwFmtFtn& rFtn ) aCntnt.push_back( &rFtn ); } -WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt) +WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd) : - maDateTime( DateTime::EMPTY ) + maDateTime( DateTime::EMPTY ), + m_nRangeStart(nRangeStart), + m_nRangeEnd(nRangeEnd) { mpRichText = pPostIt->GetTextObject(); if (!mpRichText) @@ -1960,17 +1962,33 @@ WW8_Annotation::WW8_Annotation(const SwPostItField* pPostIt) WW8_Annotation::WW8_Annotation(const SwRedlineData* pRedline) : mpRichText(0), - maDateTime( DateTime::EMPTY ) + maDateTime( DateTime::EMPTY ), + m_nRangeStart(0), + m_nRangeEnd(0) { msSimpleText = pRedline->GetComment(); msOwner = SW_MOD()->GetRedlineAuthor(pRedline->GetAuthor()); maDateTime = pRedline->GetTimeStamp(); } +void WW8_WrPlcAnnotations::AddRangeStartPosition( WW8_CP nStartCp) +{ + m_nLastRangeStartPos = nStartCp; +} + void WW8_WrPlcAnnotations::Append( WW8_CP nCp, const SwPostItField *pPostIt ) { aCps.push_back( nCp ); - WW8_Annotation* p = new WW8_Annotation(pPostIt); + WW8_Annotation* p; + if( m_nLastRangeStartPos != -1 ) + { + p = new WW8_Annotation(pPostIt, m_nLastRangeStartPos, nCp); + m_nLastRangeStartPos = -1; + } + else + { + p = new WW8_Annotation(pPostIt, nCp, nCp); + } aCntnt.push_back( p ); } @@ -2144,11 +2162,19 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, { case TXT_ATN: { + std::vector<WW8_CP> aRangeStartPos; + std::vector<WW8_CP> aRangeEndPos; // then write first the GrpXstAtnOwners for ( i = 0; i < nLen; ++i ) { const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i]; + aStrArr.push_back(std::pair<String,String>(rAtn.msOwner,rAtn.m_sInitials)); + if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd ) + { + aRangeStartPos.push_back(rAtn.m_nRangeStart); + aRangeEndPos.push_back(rAtn.m_nRangeEnd); + } } //sort and remove duplicates @@ -2181,6 +2207,67 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, nFcStart = rWrt.pTableStrm->Tell(); rFib.lcbGrpStAtnOwners = nFcStart - rFib.fcGrpStAtnOwners; + // Commented text ranges + if ( rWrt.bWrtWW8 ) + { + if( aRangeStartPos.size() > 0 ) + { + // Commented text ranges starting positions (Plcfbkf.aCP) + rFib.fcPlcfAtnbkf = nFcStart; + for ( i = 0; i < aRangeStartPos.size(); ++i ) + { + SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i] ); + } + SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeStartPos[i-1] + 1); + + // Commented text ranges additional informations (Plcfbkf.aFBKF) + for ( i = 0; i < aRangeStartPos.size(); ++i ) + { + SwWW8Writer::WriteShort( *rWrt.pTableStrm, i ); // FBKF.ibkl + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc + } + + nFcStart = rWrt.pTableStrm->Tell(); + rFib.lcbPlcfAtnbkf = nFcStart - rFib.fcPlcfAtnbkf; + + // Commented text ranges ending positions (PlcfBkl.aCP) + rFib.fcPlcfAtnbkl = nFcStart; + for ( i = 0; i < aRangeEndPos.size(); ++i ) + { + SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i] ); + } + SwWW8Writer::WriteLong( *rWrt.pTableStrm, aRangeEndPos[i-1] + 1); + + // Commented text ranges additional informations (Plcfbkl.aFBKF) + for ( i = 0; i < aRangeEndPos.size(); ++i ) + { + SwWW8Writer::WriteShort( *rWrt.pTableStrm, i ); // FBKF.ibkl + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // FBKF.bkc + } + + nFcStart = rWrt.pTableStrm->Tell(); + rFib.lcbPlcfAtnbkl = nFcStart - rFib.fcPlcfAtnbkl; + + // Commented text ranges as bookmarks (SttbfAtnBkmk) + rFib.fcSttbfAtnbkmk = nFcStart; + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xFFFF ); // SttbfAtnBkmk.fExtend + SwWW8Writer::WriteShort( *rWrt.pTableStrm, aRangeStartPos.size() ); // SttbfAtnBkmk.cData + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0xA ); // SttbfAtnBkmk.cbExtra + + for ( i = 0; i < aRangeStartPos.size(); ++i ) + { + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); // SttbfAtnBkmk.cchData + // One ATNBE structure for all text ranges + SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0x0100 ); // ATNBE.bmc + SwWW8Writer::WriteLong( *rWrt.pTableStrm, i ); // ATNBE.lTag + SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); // ATNBE.lTagOld + } + + nFcStart = rWrt.pTableStrm->Tell(); + rFib.lcbSttbfAtnbkmk = nFcStart - rFib.fcSttbfAtnbkmk; + } + } + // Write the extended >= Word XP ATLD records if( rWrt.bWrtWW8 ) { @@ -2265,6 +2352,7 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, if ( TXT_ATN == nTTyp ) { + sal_uInt16 nlTag = 0; for ( i = 0; i < nLen; ++i ) { const WW8_Annotation& rAtn = *(const WW8_Annotation*)aCntnt[i]; @@ -2314,7 +2402,13 @@ void WW8_WrPlcSubDoc::WriteGenericPlc( WW8Export& rWrt, sal_uInt8 nTTyp, SwWW8Writer::WriteShort( *rWrt.pTableStrm, nFndPos ); SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); SwWW8Writer::WriteShort( *rWrt.pTableStrm, 0 ); - SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); + if( rAtn.m_nRangeStart != rAtn.m_nRangeEnd ) + { + SwWW8Writer::WriteLong( *rWrt.pTableStrm, nlTag ); + ++nlTag; + } + else + SwWW8Writer::WriteLong( *rWrt.pTableStrm, -1 ); } } else diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index bfbbe03b0896..9c4b2671edc2 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -1189,7 +1189,8 @@ struct WW8_Annotation String msOwner; String m_sInitials; DateTime maDateTime; - WW8_Annotation(const SwPostItField* pPostIt); + WW8_CP m_nRangeStart, m_nRangeEnd; + WW8_Annotation(const SwPostItField* pPostIt, WW8_CP nRangeStart, WW8_CP nRangeEnd); WW8_Annotation(const SwRedlineData* pRedline); }; @@ -1200,10 +1201,13 @@ private: WW8_WrPlcAnnotations(const WW8_WrPlcAnnotations&); WW8_WrPlcAnnotations& operator=(WW8_WrPlcAnnotations&); std::set<const SwRedlineData*> maProcessedRedlines; + + WW8_CP m_nLastRangeStartPos; public: - WW8_WrPlcAnnotations() {} + WW8_WrPlcAnnotations(): m_nLastRangeStartPos(-1){} ~WW8_WrPlcAnnotations(); + void AddRangeStartPosition( WW8_CP nStartCp ); void Append( WW8_CP nCp, const SwPostItField* pPostIt ); void Append( WW8_CP nCp, const SwRedlineData* pRedLine ); bool IsNewRedlineComment( const SwRedlineData* pRedLine ); diff --git a/sw/source/filter/ww8/ww8atr.cxx b/sw/source/filter/ww8/ww8atr.cxx index d21134459d4b..fa1a3be6e8b0 100644 --- a/sw/source/filter/ww8/ww8atr.cxx +++ b/sw/source/filter/ww8/ww8atr.cxx @@ -2465,6 +2465,11 @@ void WW8AttributeOutput::PostitField( const SwField* pFld ) m_rWW8Export.WritePostItBegin( m_rWW8Export.pO ); } +void WW8AttributeOutput::WritePostitFieldStart() +{ + m_rWW8Export.pAtn->AddRangeStartPosition( m_rWW8Export.Fc2Cp( m_rWW8Export.Strm().Tell() ) ); +} + bool WW8AttributeOutput::DropdownField( const SwField* pFld ) { bool bExpand = true; diff --git a/sw/source/filter/ww8/ww8attributeoutput.hxx b/sw/source/filter/ww8/ww8attributeoutput.hxx index 4c64635c62db..a9693ad281b6 100644 --- a/sw/source/filter/ww8/ww8attributeoutput.hxx +++ b/sw/source/filter/ww8/ww8attributeoutput.hxx @@ -393,6 +393,8 @@ protected: virtual bool DropdownField( const SwField* pFld ); virtual bool PlaceholderField( const SwField* pFld ); + virtual void WritePostitFieldStart(); + virtual bool AnalyzeURL( const String& rURL, const String& rTarget, String* pLinkURL, String* pMark ); /// Reference to the export, where to get the data from |