summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@suse.cz>2013-04-05 14:54:19 +0200
committerMiklos Vajna <vmiklos@suse.cz>2013-04-05 15:24:45 +0200
commit13183219b7bd39b7a5c8088b2679e346c4f3280c (patch)
treece28bdec3d14ac8d1d22fd77ed59cdde64b7a132
parentd526e48912deeb44061ff570d715c31ca45f77b8 (diff)
DOCX export of w:numPicBullet
Change-Id: Ib8bcfb6bc63a5f14fbc36edc39a907b4955628e9
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.cxx43
-rw-r--r--sw/source/filter/ww8/docxattributeoutput.hxx3
-rw-r--r--sw/source/filter/ww8/docxexport.cxx85
-rw-r--r--sw/source/filter/ww8/docxexport.hxx8
4 files changed, 137 insertions, 2 deletions
diff --git a/sw/source/filter/ww8/docxattributeoutput.cxx b/sw/source/filter/ww8/docxattributeoutput.cxx
index 0ffc3a12267b..d5341cad5d4c 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 2591f0b13f6d..7c33d0764aae 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 74854fa32d77..42cb1038a0e1 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 203dbea7e317..797dd944b8e1 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 );