[Libreoffice-commits] core.git: 5 commits - desktop/source sc/source sd/source vcl/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Mon Apr 28 08:39:45 PDT 2014
desktop/source/lib/init.cxx | 40 +++++++++++++++---
sc/source/filter/html/htmlexp.cxx | 81 +++++++++++++++++++-------------------
sd/source/filter/html/htmlex.cxx | 52 ++++++++++++++++++++++--
sd/source/filter/html/htmlex.hxx | 4 +
vcl/source/filter/wmf/winmtf.cxx | 22 ++--------
vcl/source/filter/wmf/winmtf.hxx | 2
vcl/source/filter/wmf/winwmf.cxx | 14 ++++++
7 files changed, 145 insertions(+), 70 deletions(-)
New commits:
commit 6e793fdb9f349e650cf3bed47cd900119147c442
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Apr 28 17:37:43 2014 +0200
sd html: Support export of any text objects (draw) and groups
Change-Id: Ied2de0a076db722df8366e866ae66846f3fb2854
diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx
index dd69ce4..e6f163d 100644
--- a/sd/source/filter/html/htmlex.cxx
+++ b/sd/source/filter/html/htmlex.cxx
@@ -62,13 +62,16 @@
#include <svl/style.hxx>
#include <editeng/frmdiritem.hxx>
#include <svx/svdoutl.hxx>
+#include <svx/svdogrp.hxx>
#include <tools/urlobj.hxx>
#include <vcl/bmpacc.hxx>
#include <svtools/sfxecode.hxx>
#include <com/sun/star/beans/PropertyState.hpp>
#include <tools/resmgr.hxx>
-#include "comphelper/anytostring.hxx"
-#include "cppuhelper/exc_hlp.hxx"
+#include <comphelper/anytostring.hxx>
+#include <cppuhelper/exc_hlp.hxx>
+#include <basegfx/polygon/b2dpolygon.hxx>
+#include <svx/svdotable.hxx>
#include "drawdoc.hxx"
#include "htmlpublishmode.hxx"
@@ -80,9 +83,6 @@
#include "imapinfo.hxx"
#include "sdresid.hxx"
#include "buttonset.hxx"
-#include <basegfx/polygon/b2dpolygon.hxx>
-
-#include <svx/svdotable.hxx>
using namespace ::com::sun::star;
using namespace ::com::sun::star::uno;
@@ -1218,6 +1218,23 @@ OUString HtmlExport::CreateTextForPage(SdrOutliner* pOutliner, SdPage* pPage,
switch (eKind)
{
+ case PRESOBJ_NONE:
+ {
+ if (pObject->GetObjIdentifier() == OBJ_GRUP)
+ {
+ SdrObjGroup* pObjectGroup = (SdrObjGroup*) pObject;
+ WriteObjectGroup(aStr, pObjectGroup, pOutliner, rBackgroundColor, false);
+ }
+ else
+ {
+ if (pObject->GetOutlinerParaObject())
+ {
+ WriteOutlinerParagraph(aStr, pOutliner, pObject->GetOutlinerParaObject(), rBackgroundColor, false);
+ }
+ }
+ }
+ break;
+
case PRESOBJ_TABLE:
{
SdrTableObj* pTableObject = (SdrTableObj*) pObject;
@@ -1248,6 +1265,7 @@ OUString HtmlExport::CreateTextForPage(SdrOutliner* pOutliner, SdPage* pPage,
aStr.append("</table>\r\n");
}
break;
+
case PRESOBJ_TEXT:
case PRESOBJ_OUTLINE:
{
@@ -1257,6 +1275,7 @@ OUString HtmlExport::CreateTextForPage(SdrOutliner* pOutliner, SdPage* pPage,
WriteOutlinerParagraph(aStr, pOutliner, pTextObject->GetOutlinerParaObject(), rBackgroundColor, bHeadLine);
}
break;
+
default:
break;
}
@@ -1264,6 +1283,29 @@ OUString HtmlExport::CreateTextForPage(SdrOutliner* pOutliner, SdPage* pPage,
return aStr.makeStringAndClear();
}
+void HtmlExport::WriteObjectGroup(OUStringBuffer& aStr, SdrObjGroup* pObjectGroup, SdrOutliner* pOutliner,
+ const Color& rBackgroundColor, bool bHeadLine)
+{
+ SdrObjListIter aGroupIterator(*pObjectGroup->GetSubList(), IM_DEEPNOGROUPS);
+ while (aGroupIterator.IsMore())
+ {
+ SdrObject* pCurrentObject = aGroupIterator.Next();
+ if (pCurrentObject->GetObjIdentifier() == OBJ_GRUP)
+ {
+ SdrObjGroup* pCurrentGroupObject = (SdrObjGroup*) pCurrentObject;
+ WriteObjectGroup(aStr, pCurrentGroupObject, pOutliner, rBackgroundColor, bHeadLine);
+ }
+ else
+ {
+ OutlinerParaObject* pOutlinerParagraphObject = pCurrentObject->GetOutlinerParaObject();
+ if (pOutlinerParagraphObject != NULL)
+ {
+ WriteOutlinerParagraph(aStr, pOutliner, pOutlinerParagraphObject, rBackgroundColor, bHeadLine);
+ }
+ }
+ }
+}
+
void HtmlExport::WriteOutlinerParagraph(OUStringBuffer& aStr, SdrOutliner* pOutliner,
OutlinerParaObject* pOutlinerParagraphObject,
const Color& rBackgroundColor, bool bHeadLine)
diff --git a/sd/source/filter/html/htmlex.hxx b/sd/source/filter/html/htmlex.hxx
index 58e0086..51d3359 100644
--- a/sd/source/filter/html/htmlex.hxx
+++ b/sd/source/filter/html/htmlex.hxx
@@ -55,6 +55,7 @@ class SdrOutliner;
class SdPage;
class HtmlState;
class SdrTextObj;
+class SdrObjGroup;
class SdrPage;
class SdDrawDocument;
class ButtonSet;
@@ -215,6 +216,9 @@ class HtmlExport
OutlinerParaObject* pOutlinerParagraphObject,
const Color& rBackgroundColor, bool bHeadLine);
+ void WriteObjectGroup(OUStringBuffer& aStr, SdrObjGroup* pObjectGroup, SdrOutliner* pOutliner,
+ const Color& rBackgroundColor, bool bHeadLine);
+
public:
HtmlExport(const OUString& aPath,
const css::uno::Sequence<css::beans::PropertyValue>& rParams,
commit 306b29a62f7735fb0d80b7e6e987c7921ebf2c82
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Apr 28 17:36:30 2014 +0200
libLO: add extension map for draw's formats
Change-Id: Ie447f334e3fca606323870f0ce21e85d4fc0978f
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index da4b854..3b04559 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -100,6 +100,24 @@ static const ExtensionMap aImpressExtensionMap[] =
{ NULL, NULL }
};
+static const ExtensionMap aDrawExtensionMap[] =
+{
+ { "odg", "draw8" },
+ { "fodg", "draw_ODG_FlatXML" },
+ { "html", "draw_html_Export" },
+ { "svg", "draw_svg_Export" },
+ { "swf", "draw_flash_Export" },
+ { "xhtml", "XHTML Draw File" },
+ { "vdx", "draw_Visio_Document" },
+ { "vsd", "draw_Visio_Document" },
+ { "vsdm", "draw_Visio_Document" },
+ { "vsdx", "draw_Visio_Document" },
+ { "pub", "draw_Publisher_Document" },
+ { "cdr", "draw_CorelDraw_Document" },
+ { "wpg", "draw_WordPerfect_Graphics" },
+ { NULL, NULL }
+};
+
static OUString getUString(const char* pString)
{
if (pString == NULL)
@@ -230,18 +248,24 @@ static int doc_saveAsWithOptions(LibreOfficeDocument* pThis, const char* sUrl, c
if (aDocumentService.isEmpty())
{
- gImpl->maLastExceptionMsg = "Unknown document type";
+ gImpl->maLastExceptionMsg = "unknown document type";
return false;
}
const ExtensionMap* pMap;
-
- if( aDocumentService == "com.sun.star.sheet.SpreadsheetDocument" )
- pMap = (const ExtensionMap *)aCalcExtensionMap;
- else if( aDocumentService == "com.sun.star.presentation.PresentationDocument" )
- pMap = (const ExtensionMap *)aImpressExtensionMap;
- else // for the sake of argument only writer documents ...
- pMap = (const ExtensionMap *)aWriterExtensionMap;
+ if (aDocumentService == "com.sun.star.sheet.SpreadsheetDocument")
+ pMap = (const ExtensionMap*) aCalcExtensionMap;
+ else if (aDocumentService == "com.sun.star.presentation.PresentationDocument")
+ pMap = (const ExtensionMap*) aImpressExtensionMap;
+ else if (aDocumentService == "com.sun.star.drawing.DrawingDocument")
+ pMap = (const ExtensionMap*) aDrawExtensionMap;
+ else if (aDocumentService == "com.sun.star.text.TextDocument")
+ pMap = (const ExtensionMap*) aWriterExtensionMap;
+ else
+ {
+ gImpl->maLastExceptionMsg = "unknown document mapping";
+ return false;
+ }
if (pFormat == NULL)
{
commit 2c72660137baf08e1b4611e30750970a688cbacb
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Apr 28 15:23:12 2014 +0200
sc html export: some more places to skip images
Change-Id: I1d3deb96688ea29e674b7be2fda034a75d5b92a3
diff --git a/sc/source/filter/html/htmlexp.cxx b/sc/source/filter/html/htmlexp.cxx
index eb93bc6..db08610 100644
--- a/sc/source/filter/html/htmlexp.cxx
+++ b/sc/source/filter/html/htmlexp.cxx
@@ -564,53 +564,56 @@ void ScHTMLExport::WriteBody()
// default text color black
rStrm.WriteChar( '<' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_body );
- if ( bAll && GPOS_NONE != pBrushItem->GetGraphicPos() )
+ if (!mbSkipImages)
{
- OUString aLink = pBrushItem->GetGraphicLink();
- OUString aGrfNm;
-
- // Embedded graphic -> write using WriteGraphic
- if( aLink.isEmpty() )
+ if ( bAll && GPOS_NONE != pBrushItem->GetGraphicPos() )
{
- const Graphic* pGrf = pBrushItem->GetGraphic();
- if( pGrf )
+ OUString aLink = pBrushItem->GetGraphicLink();
+ OUString aGrfNm;
+
+ // Embedded graphic -> write using WriteGraphic
+ if( aLink.isEmpty() )
{
- // Save graphic as (JPG) file
- aGrfNm = aStreamPath;
- sal_uInt16 nErr = XOutBitmap::WriteGraphic( *pGrf, aGrfNm,
- "JPG", XOUTBMP_USE_NATIVE_IF_POSSIBLE );
- if( !nErr ) // Contains errors, as we have nothing to output
+ const Graphic* pGrf = pBrushItem->GetGraphic();
+ if( pGrf )
{
- aGrfNm = URIHelper::SmartRel2Abs(
- INetURLObject(aBaseURL),
- aGrfNm, URIHelper::GetMaybeFileHdl(), true, false);
+ // Save graphic as (JPG) file
+ aGrfNm = aStreamPath;
+ sal_uInt16 nErr = XOutBitmap::WriteGraphic( *pGrf, aGrfNm,
+ "JPG", XOUTBMP_USE_NATIVE_IF_POSSIBLE );
+ if( !nErr ) // Contains errors, as we have nothing to output
+ {
+ aGrfNm = URIHelper::SmartRel2Abs(
+ INetURLObject(aBaseURL),
+ aGrfNm, URIHelper::GetMaybeFileHdl(), true, false);
+ if ( HasCId() )
+ MakeCIdURL( aGrfNm );
+ aLink = aGrfNm;
+ }
+ }
+ }
+ else
+ {
+ aGrfNm = aLink;
+ if( bCopyLocalFileToINet || HasCId() )
+ {
+ CopyLocalFileToINet( aGrfNm, aStreamPath );
if ( HasCId() )
MakeCIdURL( aGrfNm );
- aLink = aGrfNm;
}
+ else
+ aGrfNm = URIHelper::SmartRel2Abs(
+ INetURLObject(aBaseURL),
+ aGrfNm, URIHelper::GetMaybeFileHdl(), true, false);
+ aLink = aGrfNm;
}
- }
- else
- {
- aGrfNm = aLink;
- if( bCopyLocalFileToINet || HasCId() )
+ if( !aLink.isEmpty() )
{
- CopyLocalFileToINet( aGrfNm, aStreamPath );
- if ( HasCId() )
- MakeCIdURL( aGrfNm );
+ rStrm.WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_background ).WriteCharPtr( "=\"" );
+ OUT_STR( URIHelper::simpleNormalizedMakeRelative(
+ aBaseURL,
+ aLink ) ).WriteChar( '\"' );
}
- else
- aGrfNm = URIHelper::SmartRel2Abs(
- INetURLObject(aBaseURL),
- aGrfNm, URIHelper::GetMaybeFileHdl(), true, false);
- aLink = aGrfNm;
- }
- if( !aLink.isEmpty() )
- {
- rStrm.WriteChar( ' ' ).WriteCharPtr( OOO_STRING_SVTOOLS_HTML_O_background ).WriteCharPtr( "=\"" );
- OUT_STR( URIHelper::simpleNormalizedMakeRelative(
- aBaseURL,
- aLink ) ).WriteChar( '\"' );
}
}
if ( !aHTMLStyle.aBackgroundColor.GetTransparency() )
@@ -805,7 +808,7 @@ void ScHTMLExport::WriteTables()
IncIndent(-1); TAG_OFF_LF( OOO_STRING_SVTOOLS_HTML_table );
- if ( bTabHasGraphics && mbSkipImages )
+ if ( bTabHasGraphics && !mbSkipImages )
{
// the rest that is not in a cell
size_t ListSize = aGraphList.size();
@@ -844,7 +847,7 @@ void ScHTMLExport::WriteCell( SCCOL nCol, SCROW nRow, SCTAB nTab )
ScAddress aPos( nCol, nRow, nTab );
ScHTMLGraphEntry* pGraphEntry = NULL;
- if ( bTabHasGraphics )
+ if ( bTabHasGraphics && !mbSkipImages )
{
size_t ListSize = aGraphList.size();
for ( size_t i = 0; i < ListSize; ++i )
commit a9020e461803964a206d5551884b70717eed165c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Apr 28 15:16:53 2014 +0200
fdo#74336 limit the size of the non-placeable WMF image
For a non-placable WMF image the size is unknown and needs to be
calculated by using a bounding box over all elements. Sometimes
this results in a very big image which is not drawn correctly
when using dashes and dots. This change normalizes the size to
reasonable values.
Change-Id: I0e5b71fb011c5a9dff1c5cb13e29d5578570ca65
diff --git a/vcl/source/filter/wmf/winwmf.cxx b/vcl/source/filter/wmf/winwmf.cxx
index 47f48c3..22940dd 100644
--- a/vcl/source/filter/wmf/winwmf.cxx
+++ b/vcl/source/filter/wmf/winwmf.cxx
@@ -1141,6 +1141,20 @@ bool WMFReader::ReadHeader()
{
pWMF->Seek( nStrmPos + 18 ); // set the streampos to the start of the metaactions
GetPlaceableBound( aPlaceableBound, pWMF );
+
+ // The image size is not known so normalize the calculated bounds so that the
+ // resulting image is not too big
+ const long aMaxWidth = 1024;
+ const double fMaxWidth = static_cast<double>(aMaxWidth);
+ if (aPlaceableBound.GetWidth() > aMaxWidth)
+ {
+ double fRatio = aPlaceableBound.GetWidth() / fMaxWidth;
+ aPlaceableBound = Rectangle(
+ aPlaceableBound.Top() / fRatio,
+ aPlaceableBound.Left() / fRatio,
+ aPlaceableBound.Bottom() / fRatio,
+ aPlaceableBound.Right() / fRatio);
+ }
}
pWMF->Seek( nStrmPos );
commit 2ac96e52b05e9b9072788b80688a13436359b439
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Mon Apr 28 15:10:08 2014 +0200
Revert "fdo#74336 need to transform dash length / dot length / distance"
This reverts commit 17ca93a6e592d3109e47c756fcfe8ac975acae5f.
diff --git a/vcl/source/filter/wmf/winmtf.cxx b/vcl/source/filter/wmf/winmtf.cxx
index 7c4b01d..7aa7337 100644
--- a/vcl/source/filter/wmf/winmtf.cxx
+++ b/vcl/source/filter/wmf/winmtf.cxx
@@ -473,20 +473,6 @@ void WinMtfOutput::ImplMap( Font& rFont )
rFont.SetOrientation( 3600 - rFont.GetOrientation() );
}
-sal_Int32 WinMtfOutput::ImplConvertWidth(const sal_Int32 aWidth)
-{
- Size aSize(aWidth, 0);
- return ImplMap(aSize).Width();
-}
-
-void WinMtfOutput::ImplMap(LineInfo& rLineInfo)
-{
- rLineInfo.SetWidth(ImplConvertWidth(rLineInfo.GetWidth()));
- rLineInfo.SetDashLen(ImplConvertWidth(rLineInfo.GetDashLen()));
- rLineInfo.SetDotLen(ImplConvertWidth(rLineInfo.GetDotLen()));
- rLineInfo.SetDistance(ImplConvertWidth(rLineInfo.GetDistance()));
-}
-
Polygon& WinMtfOutput::ImplMap( Polygon& rPolygon )
{
sal_uInt16 nPoints = rPolygon.GetSize();
@@ -696,7 +682,9 @@ void WinMtfOutput::CreateObject( GDIObjectType eType, void* pStyle )
else if ( eType == GDI_PEN )
{
WinMtfLineStyle* pLineStyle = (WinMtfLineStyle*) pStyle;
- ImplMap(pLineStyle->aLineInfo);
+ Size aSize(pLineStyle->aLineInfo.GetWidth(), 0);
+ aSize = ImplMap(aSize);
+ pLineStyle->aLineInfo.SetWidth(aSize.Width());
}
}
sal_uInt32 nIndex;
@@ -728,7 +716,9 @@ void WinMtfOutput::CreateObject( sal_Int32 nIndex, GDIObjectType eType, void* pS
else if ( eType == GDI_PEN )
{
WinMtfLineStyle* pLineStyle = (WinMtfLineStyle*) pStyle;
- ImplMap(pLineStyle->aLineInfo);
+ Size aSize(pLineStyle->aLineInfo.GetWidth(), 0);
+ aSize = ImplMap(aSize);
+ pLineStyle->aLineInfo.SetWidth(aSize.Width());
}
}
if ( (sal_uInt32)nIndex >= vGDIObj.size() )
diff --git a/vcl/source/filter/wmf/winmtf.hxx b/vcl/source/filter/wmf/winmtf.hxx
index dfda459..bfa7a90 100644
--- a/vcl/source/filter/wmf/winmtf.hxx
+++ b/vcl/source/filter/wmf/winmtf.hxx
@@ -619,8 +619,6 @@ class WinMtfOutput
Size ImplMap( const Size& rSz );
Rectangle ImplMap( const Rectangle& rRectangle );
void ImplMap( Font& rFont );
- sal_Int32 ImplConvertWidth(const sal_Int32 aWidth);
- void ImplMap(LineInfo& rLineInfo);
Polygon& ImplMap( Polygon& rPolygon );
PolyPolygon& ImplMap( PolyPolygon& rPolyPolygon );
Polygon& ImplScale( Polygon& rPolygon );
More information about the Libreoffice-commits
mailing list