Kaydet (Commit) 13183219 authored tarafından Miklos Vajna's avatar Miklos Vajna

DOCX export of w:numPicBullet

Change-Id: Ib8bcfb6bc63a5f14fbc36edc39a907b4955628e9
üst d526e489
...@@ -3204,7 +3204,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel, ...@@ -3204,7 +3204,7 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
sal_Int16 nFirstLineIndex, sal_Int16 nFirstLineIndex,
sal_Int16 nListTabPos, sal_Int16 nListTabPos,
const String &rNumberingString, const String &rNumberingString,
const SvxBrushItem* ) const SvxBrushItem* pBrush)
{ {
m_pSerializer->startElementNS( XML_w, XML_lvl, m_pSerializer->startElementNS( XML_w, XML_lvl,
FSNS( XML_w, XML_ilvl ), OString::valueOf( sal_Int32( nLevel ) ).getStr(), FSNS( XML_w, XML_ilvl ), OString::valueOf( sal_Int32( nLevel ) ).getStr(),
...@@ -3264,6 +3264,18 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel, ...@@ -3264,6 +3264,18 @@ void DocxAttributeOutput::NumberingLevel( sal_uInt8 nLevel,
FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(), FSNS( XML_w, XML_val ), OUStringToOString( aBuffer.makeStringAndClear(), RTL_TEXTENCODING_UTF8 ).getStr(),
FSEND ); 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 // justification
const char *pJc; const char *pJc;
bool ecmaDialect = ( m_rExport.GetFilter().getVersion() == oox::core::ECMA_DIALECT ); bool ecmaDialect = ( m_rExport.GetFilter().getVersion() == oox::core::ECMA_DIALECT );
...@@ -4923,4 +4935,33 @@ bool DocxAttributeOutput::HasPostitFields() const ...@@ -4923,4 +4935,33 @@ bool DocxAttributeOutput::HasPostitFields() const
return !m_postitFields.empty(); 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: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -684,6 +684,9 @@ public: ...@@ -684,6 +684,9 @@ public:
/// VMLTextExport /// VMLTextExport
virtual void WriteOutliner(const OutlinerParaObject& rParaObj); virtual void WriteOutliner(const OutlinerParaObject& rParaObj);
virtual oox::drawingml::DrawingML& GetDrawingML(); 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_ #endif // _DOCXATTRIBUTEOUTPUT_HXX_
......
...@@ -47,6 +47,7 @@ ...@@ -47,6 +47,7 @@
#include <editeng/editobj.hxx> #include <editeng/editobj.hxx>
#include <editeng/outlobj.hxx> #include <editeng/outlobj.hxx>
#include <editeng/brushitem.hxx>
#include <docary.hxx> #include <docary.hxx>
#include <numrule.hxx> #include <numrule.hxx>
...@@ -60,6 +61,7 @@ ...@@ -60,6 +61,7 @@
#include <comphelper/string.hxx> #include <comphelper/string.hxx>
#include <rtl/ustrbuf.hxx> #include <rtl/ustrbuf.hxx>
#include <vcl/font.hxx> #include <vcl/font.hxx>
#include <vcl/svapp.hxx>
using namespace sax_fastparser; using namespace sax_fastparser;
using namespace ::comphelper; using namespace ::comphelper;
...@@ -154,7 +156,8 @@ void DocxExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ ) ...@@ -154,7 +156,8 @@ void DocxExport::AppendBookmark( const OUString& rName, bool /*bSkip*/ )
void DocxExport::ExportGrfBullet(const SwTxtNode&) 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 ) ::rtl::OString DocxExport::AddRelation( const OUString& rType, const OUString& rTarget )
...@@ -525,6 +528,81 @@ void DocxExport::WritePostitFields() ...@@ -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() void DocxExport::WriteNumbering()
{ {
if ( !pUsedNumTbl ) if ( !pUsedNumTbl )
...@@ -542,8 +620,13 @@ void DocxExport::WriteNumbering() ...@@ -542,8 +620,13 @@ void DocxExport::WriteNumbering()
pNumberingFS->startElementNS( XML_w, XML_numbering, pNumberingFS->startElementNS( XML_w, XML_numbering,
FSNS( XML_xmlns, XML_w ), "http://schemas.openxmlformats.org/wordprocessingml/2006/main", 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 ); FSEND );
BulletDefinitions();
AbstractNumberingDefinitions(); AbstractNumberingDefinitions();
NumberingDefinitions(); NumberingDefinitions();
......
...@@ -85,6 +85,8 @@ class DocxExport : public MSWordExportBase ...@@ -85,6 +85,8 @@ class DocxExport : public MSWordExportBase
DocxSettingsData settings; DocxSettingsData settings;
std::vector<const Graphic*> m_vecBulletPic;
public: public:
DocxExportFilter& GetFilter() { return *m_pFilter; }; DocxExportFilter& GetFilter() { return *m_pFilter; };
...@@ -146,6 +148,9 @@ public: ...@@ -146,6 +148,9 @@ public:
void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp); void WriteOutliner(const OutlinerParaObject& rOutliner, sal_uInt8 nTyp);
int CollectGrfsOfBullets();
int GetGrfIndex(const SvxBrushItem& rBrush);
protected: protected:
/// Format-dependant part of the actual export. /// Format-dependant part of the actual export.
virtual void ExportDocument_Impl(); virtual void ExportDocument_Impl();
...@@ -202,6 +207,9 @@ private: ...@@ -202,6 +207,9 @@ private:
/// Write word/settings.xml /// Write word/settings.xml
void WriteSettings(); 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,...) /// 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 ); sax_fastparser::XFastAttributeListRef MainXmlNamespaces( sax_fastparser::FSHelperPtr serializer );
......
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