dev/null |binary sw/qa/extras/ooxmlexport/data/i120928.docx |binary sw/qa/extras/ooxmlexport/ooxmlexport.cxx | 22 +++++++++++++ sw/qa/extras/ooxmlimport/ooxmlimport.cxx | 23 -------------- sw/source/filter/ww8/docxattributeoutput.cxx | 43 ++++++++++++++++++++++++++- sw/source/filter/ww8/docxattributeoutput.hxx | 3 + sw/source/filter/ww8/docxexport.cxx | 25 +++++++++++++++ sw/source/filter/ww8/docxexport.hxx | 3 + sw/source/filter/ww8/wrtww8.cxx | 6 +-- sw/source/filter/ww8/wrtww8.hxx | 11 +++--- 10 files changed, 103 insertions(+), 33 deletions(-)
New commits: commit 0644a20605965b36fcc983e4c1158820fd858726 Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Apr 5 15:12:30 2013 +0200 Get rid of copy&paste by moving code from WW8Export to MSWordExportBase Change-Id: I1a36fb3d20d1e67484668b7ba8feb1c96505af59 diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 42cb103..e7bec6f 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -528,66 +528,6 @@ void DocxExport::WritePostitFields() } } -int DocxExport::CollectGrfsOfBullets() -{ - m_vecBulletPic.clear(); - - if ( pDoc ) - { - int nCountRule = pDoc->GetNumRuleTbl().size(); - for (int n = 0; n < nCountRule; ++n) - { - const SwNumRule &rRule = *( pDoc->GetNumRuleTbl().at(n) ); - sal_uInt16 nLevels = rRule.IsContinusNum() ? 1 : 9; - for (sal_uInt16 nLvl = 0; nLvl < nLevels; ++nLvl) - { - const SwNumFmt &rFmt = rRule.Get(nLvl); - if (SVX_NUM_BITMAP != rFmt.GetNumberingType()) - { - continue; - } - const Graphic *pGraf = rFmt.GetBrush()? rFmt.GetBrush()->GetGraphic():0; - if ( pGraf ) - { - bool bHas = false; - for (unsigned i = 0; i < m_vecBulletPic.size(); ++i) - { - if (m_vecBulletPic[i]->GetChecksum() == pGraf->GetChecksum()) - { - bHas = true; - break; - } - } - if (!bHas) - { - m_vecBulletPic.push_back(pGraf); - } - } - } - } - } - - return m_vecBulletPic.size(); -} - -int DocxExport::GetGrfIndex(const SvxBrushItem& rBrush) -{ - int nIndex = -1; - if ( rBrush.GetGraphic() ) - { - for (unsigned i = 0; i < m_vecBulletPic.size(); ++i) - { - if (m_vecBulletPic[i]->GetChecksum() == rBrush.GetGraphic()->GetChecksum()) - { - nIndex = i; - break; - } - } - } - - return nIndex; -} - void DocxExport::BulletDefinitions() { for (size_t i = 0; i < m_vecBulletPic.size(); ++i) diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 797dd94..ac5637d 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -85,8 +85,6 @@ class DocxExport : public MSWordExportBase DocxSettingsData settings; - std::vector<const Graphic*> m_vecBulletPic; - public: DocxExportFilter& GetFilter() { return *m_pFilter; }; @@ -148,9 +146,6 @@ public: void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp); - int CollectGrfsOfBullets(); - int GetGrfIndex(const SvxBrushItem& rBrush); - protected: /// Format-dependant part of the actual export. virtual void ExportDocument_Impl(); diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx index a666980..86e3f57 100644 --- a/sw/source/filter/ww8/wrtww8.cxx +++ b/sw/source/filter/ww8/wrtww8.cxx @@ -1406,7 +1406,7 @@ void WW8Export::AppendBookmark( const rtl::OUString& rName, bool bSkip ) } // #i120928 collect all the graphics of bullets applied to paragraphs -int WW8Export::CollectGrfsOfBullets() const +int MSWordExportBase::CollectGrfsOfBullets() { m_vecBulletPic.clear(); @@ -1505,8 +1505,8 @@ void WW8Export::OutGrfBullets(const sw::Frame & rFrame) Set_UInt8( pArr, nAttrMagicIdx++ ); pChpPlc->AppendFkpEntry( Strm().Tell(), static_cast< short >(pArr - aArr), aArr ); } -//Achieve the index position -int WW8Export::GetGrfIndex(const SvxBrushItem& rBrush) + +int MSWordExportBase::GetGrfIndex(const SvxBrushItem& rBrush) { int nIndex = -1; if ( rBrush.GetGraphic() ) diff --git a/sw/source/filter/ww8/wrtww8.hxx b/sw/source/filter/ww8/wrtww8.hxx index aae74df..8628545 100644 --- a/sw/source/filter/ww8/wrtww8.hxx +++ b/sw/source/filter/ww8/wrtww8.hxx @@ -747,6 +747,8 @@ public: const SfxPoolItem* HasItem( sal_uInt16 nWhich ) const; + /// Returns the index of a picture bullet, used in numberings. + int GetGrfIndex(const SvxBrushItem& rBrush); protected: /// Format-dependant part of the actual export. @@ -784,7 +786,6 @@ protected: /// Return value indicates if an inherited outline numbering is suppressed. virtual bool DisallowInheritingOutlineNumbering(const SwFmt &rFmt) = 0; -protected: /// Output SwStartNode virtual void OutputStartNode( const SwStartNode& ); @@ -823,6 +824,10 @@ protected: const NfKeywordTable & GetNfKeywordTable(); + /// Populates m_vecBulletPic with all the bullet graphics used by numberings. + int CollectGrfsOfBullets(); + std::vector<const Graphic*> m_vecBulletPic; ///< Vector to record all the graphics of bullets + public: MSWordExportBase( SwDoc *pDocument, SwPaM *pCurrentPam, SwPaM *pOriginalPam ); virtual ~MSWordExportBase(); @@ -912,8 +917,6 @@ public: sal_uInt8 bWrtWW8 : 1; ///< Write WW95 (false) or WW97 (true) file format - mutable std::vector<const Graphic*> m_vecBulletPic; ///< Vector to record all the graphics of bullets - protected: SwWW8Writer *m_pWriter; ///< Pointer to the writer WW8AttributeOutput *m_pAttrOutput; ///< Converting attributes to stream data @@ -1009,9 +1012,7 @@ public: virtual void AppendBookmark( const rtl::OUString& rName, bool bSkip = false ); virtual void ExportGrfBullet(const SwTxtNode& rNd); - int CollectGrfsOfBullets() const; void OutGrfBullets(const sw::Frame &rFrame); - int GetGrfIndex(const SvxBrushItem& rBrush); void MoveFieldMarks(sal_uLong nFrom, sal_uLong nTo); commit e63950dc82ad7b30763c22391aec767111cf97d5 Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Apr 5 15:01:31 2013 +0200 w:numPicBullet export testcase Change-Id: Ia8a32b6d9fcb53e3974940c173edb2fe4c9e1ab3 diff --git a/sw/qa/extras/ooxmlexport/data/i120928.docx b/sw/qa/extras/ooxmlexport/data/i120928.docx new file mode 100644 index 0000000..ce78653 Binary files /dev/null and b/sw/qa/extras/ooxmlexport/data/i120928.docx differ diff --git a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx index 05908c4..35bb3b6 100644 --- a/sw/qa/extras/ooxmlexport/ooxmlexport.cxx +++ b/sw/qa/extras/ooxmlexport/ooxmlexport.cxx @@ -86,6 +86,7 @@ public: void testTableStylerPrSz(); void testMathLiteral(); void testFdo48557(); + void testI120928(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -132,6 +133,7 @@ void Test::run() {"table-style-rPr-sz.docx", &Test::testTableStylerPrSz}, {"math-literal.docx", &Test::testMathLiteral}, {"fdo48557.odt", &Test::testFdo48557}, + {"i120928.docx", &Test::testI120928}, }; // Don't test the first import of these, for some reason those tests fail const char* aBlacklist[] = { @@ -672,6 +674,26 @@ void Test::testFdo48557() CPPUNIT_ASSERT_EQUAL(sal_Int32(150), getProperty<sal_Int32>(xFrame, "BottomBorderDistance")); } +void Test::testI120928() +{ + // w:numPicBullet was ignored, leading to missing graphic bullet in numbering. + uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); + uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); + uno::Sequence<beans::PropertyValue> aProps; + xLevels->getByIndex(0) >>= aProps; // 1st level + + bool bIsGraphic = false; + for (int i = 0; i < aProps.getLength(); ++i) + { + const beans::PropertyValue& rProp = aProps[i]; + + if (rProp.Name == "NumberingType") + CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>()); + else if (rProp.Name == "GraphicURL") + bIsGraphic = true; + } + CPPUNIT_ASSERT_EQUAL(true, bIsGraphic); +} CPPUNIT_TEST_SUITE_REGISTRATION(Test); diff --git a/sw/qa/extras/ooxmlimport/data/i120928.docx b/sw/qa/extras/ooxmlimport/data/i120928.docx deleted file mode 100644 index ce78653..0000000 Binary files a/sw/qa/extras/ooxmlimport/data/i120928.docx and /dev/null differ diff --git a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx index 14228f1..7c4051c 100644 --- a/sw/qa/extras/ooxmlimport/ooxmlimport.cxx +++ b/sw/qa/extras/ooxmlimport/ooxmlimport.cxx @@ -124,7 +124,6 @@ public: void testFdo60922(); void testFdo59273(); void testTableWidth(); - void testI120928(); CPPUNIT_TEST_SUITE(Test); #if !defined(MACOSX) && !defined(WNT) @@ -200,7 +199,6 @@ void Test::run() {"fdo60922.docx", &Test::testFdo60922}, {"fdo59273.docx", &Test::testFdo59273}, {"table_width.docx", &Test::testTableWidth}, - {"i120928.docx", &Test::testI120928}, }; header(); for (unsigned int i = 0; i < SAL_N_ELEMENTS(aMethods); ++i) @@ -1315,27 +1313,6 @@ void Test::testTableWidth() CPPUNIT_ASSERT_EQUAL(true, bool(getProperty<sal_Bool>(xTables->getByIndex(0), "IsWidthRelative"))); } -void Test::testI120928() -{ - // w:numPicBullet was ignored, leading to missing graphic bullet in numbering. - uno::Reference<beans::XPropertySet> xPropertySet(getStyles("NumberingStyles")->getByName("WWNum1"), uno::UNO_QUERY); - uno::Reference<container::XIndexAccess> xLevels(xPropertySet->getPropertyValue("NumberingRules"), uno::UNO_QUERY); - uno::Sequence<beans::PropertyValue> aProps; - xLevels->getByIndex(0) >>= aProps; // 1st level - - bool bIsGraphic = false; - for (int i = 0; i < aProps.getLength(); ++i) - { - const beans::PropertyValue& rProp = aProps[i]; - - if (rProp.Name == "NumberingType") - CPPUNIT_ASSERT_EQUAL(style::NumberingType::BITMAP, rProp.Value.get<sal_Int16>()); - else if (rProp.Name == "GraphicURL") - bIsGraphic = true; - } - CPPUNIT_ASSERT_EQUAL(true, bIsGraphic); -} - CPPUNIT_TEST_SUITE_REGISTRATION(Test); CPPUNIT_PLUGIN_IMPLEMENT(); commit 13183219b7bd39b7a5c8088b2679e346c4f3280c Author: Miklos Vajna <vmik...@suse.cz> Date: Fri Apr 5 14:54:19 2013 +0200 DOCX export of w:numPicBullet Change-Id: Ib8bcfb6bc63a5f14fbc36edc39a907b4955628e9 diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx index 0ffc3a1..d5341ca 100644 --- a/sw/source/filter/ww8/docxattributeoutput.cxx +++ b/sw/source/filter/ww8/docxattributeoutput.cxx @@ -3204,7 +3204,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel, sal_Int16 nFirstLineIndex, sal_Int16 nListTabPos, const String &rNumberingString, - const SvxBrushItem* ) + const SvxBrushItem* pBrush) { m_pSerializer->startElementNS( XML_w, XML_lvl, FSNS( XML_w, XML_ilvl ), OString::valueOf( sal_Int32( nLevel ) ).getStr(), @@ -3264,6 +3264,18 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel, FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), FSEND ); + // bullet + if (nNumberingType == SVX_NUM_BITMAP && pBrush) + { + int nIndex = m_rExport.GetGrfIndex(*pBrush); + if (nIndex != -1) + { + m_pSerializer->singleElementNS(XML_w, XML_lvlPicBulletId, + FSNS(XML_w, XML_val), OString::number(nIndex).getStr(), + FSEND); + } + } + // justification const char *pJc; bool ecmaDialect = ( m_rExport.GetFilter().getVersion() == oox::core::ECMA_DIALECT ); @@ -4923,4 +4935,33 @@ bool DocxAttributeOutput::HasPostitFields() const return !m_postitFields.empty(); } +void DocxAttributeOutput::BulletDefinition(int nId, const Graphic& rGraphic, Size aSize) +{ + m_pSerializer->startElementNS(XML_w, XML_numPicBullet, + FSNS(XML_w, XML_numPicBulletId), OString::number(nId).getStr(), + FSEND); + + OStringBuffer aStyle; + // Size is in twips, we need it in points. + aStyle.append("width:").append(double(aSize.Width()) / 20); + aStyle.append("pt;height:").append(double(aSize.Height()) / 20).append("pt"); + m_pSerializer->startElementNS( XML_w, XML_pict, FSEND); + m_pSerializer->startElementNS( XML_v, XML_shape, + XML_style, aStyle.getStr(), + FSNS(XML_o, XML_bullet), "t", + FSEND); + + m_rDrawingML.SetFS(m_pSerializer); + OUString aRelId = m_rDrawingML.WriteImage(rGraphic); + m_pSerializer->singleElementNS( XML_v, XML_imagedata, + FSNS(XML_r, XML_id), OUStringToOString(aRelId, RTL_TEXTENCODING_UTF8), + FSNS(XML_o, XML_title), "", + FSEND); + + m_pSerializer->endElementNS(XML_v, XML_shape); + m_pSerializer->endElementNS(XML_w, XML_pict); + + m_pSerializer->endElementNS(XML_w, XML_numPicBullet); +} + /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/sw/source/filter/ww8/docxattributeoutput.hxx b/sw/source/filter/ww8/docxattributeoutput.hxx index 2591f0b..7c33d07 100644 --- a/sw/source/filter/ww8/docxattributeoutput.hxx +++ b/sw/source/filter/ww8/docxattributeoutput.hxx @@ -684,6 +684,9 @@ public: /// VMLTextExport virtual void WriteOutliner(const OutlinerParaObject& rParaObj); virtual oox::drawingml::DrawingML& GetDrawingML(); + + /// Exports the definition (image, size) of a single numbering picture bullet. + void BulletDefinition(int nId, const Graphic& rGraphic, Size aSize); }; #endif // _DOCXATTRIBUTEOUTPUT_HXX_ diff --git a/sw/source/filter/ww8/docxexport.cxx b/sw/source/filter/ww8/docxexport.cxx index 74854fa..42cb103 100644 --- a/sw/source/filter/ww8/docxexport.cxx +++ b/sw/source/filter/ww8/docxexport.cxx @@ -47,6 +47,7 @@ #include <editeng/editobj.hxx> #include <editeng/outlobj.hxx> +#include <editeng/brushitem.hxx> #include <docary.hxx> #include <numrule.hxx> @@ -60,6 +61,7 @@ #include <comphelper/string.hxx> #include <rtl/ustrbuf.hxx> #include <vcl/font.hxx> +#include <vcl/svapp.hxx> using namespace sax_fastparser; using namespace ::comphelper; @@ -154,7 +156,8 @@ void DocxExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ ) void DocxExport::ExportGrfBullet(const SwTxtNode&) { - SAL_INFO("sw.docx", "TODO: " << OSL_THIS_FUNC); + // Just collect the bullets for now, numbering.xml is not yet started. + CollectGrfsOfBullets(); } ::rtl::OString DocxExport::AddRelation( const OUString& rType, const OUString& rTarget ) @@ -525,6 +528,81 @@ void DocxExport::WritePostitFields() } } +int DocxExport::CollectGrfsOfBullets() +{ + m_vecBulletPic.clear(); + + if ( pDoc ) + { + int nCountRule = pDoc->GetNumRuleTbl().size(); + for (int n = 0; n < nCountRule; ++n) + { + const SwNumRule &rRule = *( pDoc->GetNumRuleTbl().at(n) ); + sal_uInt16 nLevels = rRule.IsContinusNum() ? 1 : 9; + for (sal_uInt16 nLvl = 0; nLvl < nLevels; ++nLvl) + { + const SwNumFmt &rFmt = rRule.Get(nLvl); + if (SVX_NUM_BITMAP != rFmt.GetNumberingType()) + { + continue; + } + const Graphic *pGraf = rFmt.GetBrush()? rFmt.GetBrush()->GetGraphic():0; + if ( pGraf ) + { + bool bHas = false; + for (unsigned i = 0; i < m_vecBulletPic.size(); ++i) + { + if (m_vecBulletPic[i]->GetChecksum() == pGraf->GetChecksum()) + { + bHas = true; + break; + } + } + if (!bHas) + { + m_vecBulletPic.push_back(pGraf); + } + } + } + } + } + + return m_vecBulletPic.size(); +} + +int DocxExport::GetGrfIndex(const SvxBrushItem& rBrush) +{ + int nIndex = -1; + if ( rBrush.GetGraphic() ) + { + for (unsigned i = 0; i < m_vecBulletPic.size(); ++i) + { + if (m_vecBulletPic[i]->GetChecksum() == rBrush.GetGraphic()->GetChecksum()) + { + nIndex = i; + break; + } + } + } + + return nIndex; +} + +void DocxExport::BulletDefinitions() +{ + for (size_t i = 0; i < m_vecBulletPic.size(); ++i) + { + const MapMode aMapMode(MAP_TWIP); + const Graphic& rGraphic = *m_vecBulletPic[i]; + Size aSize(rGraphic.GetPrefSize()); + if (MAP_PIXEL == rGraphic.GetPrefMapMode().GetMapUnit()) + aSize = Application::GetDefaultDevice()->PixelToLogic(aSize, aMapMode); + else + aSize = OutputDevice::LogicToLogic(aSize,rGraphic.GetPrefMapMode(), aMapMode); + m_pAttrOutput->BulletDefinition(i, rGraphic, aSize); + } +} + void DocxExport::WriteNumbering() { if ( !pUsedNumTbl ) @@ -542,8 +620,13 @@ void DocxExport::WriteNumbering() pNumberingFS->startElementNS( XML_w, XML_numbering, FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", + FSNS( XML_xmlns, XML_o ), "urn:schemas-microsoft-com:office:office", + FSNS( XML_xmlns, XML_r ), "http://schemas.openxmlformats.org/officeDocument/2006/relationships", + FSNS( XML_xmlns, XML_v ), "urn:schemas-microsoft-com:vml", FSEND ); + BulletDefinitions(); + AbstractNumberingDefinitions(); NumberingDefinitions(); diff --git a/sw/source/filter/ww8/docxexport.hxx b/sw/source/filter/ww8/docxexport.hxx index 203dbea..797dd94 100644 --- a/sw/source/filter/ww8/docxexport.hxx +++ b/sw/source/filter/ww8/docxexport.hxx @@ -85,6 +85,8 @@ class DocxExport : public MSWordExportBase DocxSettingsData settings; + std::vector<const Graphic*> m_vecBulletPic; + public: DocxExportFilter& GetFilter() { return *m_pFilter; }; @@ -146,6 +148,9 @@ public: void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp); + int CollectGrfsOfBullets(); + int GetGrfIndex(const SvxBrushItem& rBrush); + protected: /// Format-dependant part of the actual export. virtual void ExportDocument_Impl(); @@ -202,6 +207,9 @@ private: /// Write word/settings.xml void WriteSettings(); + /// Write the numbering picture bullets part of word/numbering.xml + void BulletDefinitions(); + /// All xml namespaces to be used at the top of any text .xml file (main doc, headers, footers,...) sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer ); _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits