[Libreoffice-commits] core.git: 8 commits - desktop/inc desktop/source sw/inc sw/qa sw/source
Tomaž Vajngerl
tomaz.vajngerl at collabora.com
Tue Apr 8 04:16:40 PDT 2014
desktop/inc/liblibreoffice.h | 27 +--
desktop/inc/liblibreoffice.hxx | 57 ++++---
desktop/source/lib/init.cxx | 257 ++++++++++++++++----------------
sw/inc/shellio.hxx | 2
sw/qa/extras/htmlexport/htmlexport.cxx | 63 ++++++-
sw/qa/extras/inc/swmodeltestbase.hxx | 80 ++++++++-
sw/source/filter/html/htmlflywriter.cxx | 3
sw/source/filter/html/wrthtml.cxx | 23 ++
sw/source/filter/html/wrthtml.hxx | 4
sw/source/filter/writer/writer.cxx | 10 -
10 files changed, 342 insertions(+), 184 deletions(-)
New commits:
commit 011cd3926faf8216d3bcee4c79fd307d2e236e23
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Tue Apr 8 09:06:05 2014 +0200
sw html: HTML export test - option with or without "skipImages"
Additionally add loading of HTML document and parsing the document
with libxml - to be able to assert with xpath expression.
Change-Id: I7c62082a124c3705626cd76c8a4cdabc16372399
diff --git a/sw/qa/extras/htmlexport/htmlexport.cxx b/sw/qa/extras/htmlexport/htmlexport.cxx
index ed264e2..18b2862 100644
--- a/sw/qa/extras/htmlexport/htmlexport.cxx
+++ b/sw/qa/extras/htmlexport/htmlexport.cxx
@@ -16,13 +16,37 @@
#include <swmodule.hxx>
#include <usrpref.hxx>
+#include <libxml/HTMLparser.h>
+#include <libxml/HTMLtree.h>
+
class Test : public SwModelTestBase
{
+private:
+ FieldUnit m_eUnit;
+
public:
- Test()
- : SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)"),
+ Test() :
+ SwModelTestBase("/sw/qa/extras/htmlexport/data/", "HTML (StarWriter)"),
m_eUnit(FUNIT_NONE)
+ {}
+
+protected:
+ htmlDocPtr parseHtml()
{
+ SvFileStream aFileStream(m_aTempFile.GetURL(), STREAM_READ);
+ aFileStream.Seek(STREAM_SEEK_TO_END);
+ sal_Size nSize = aFileStream.Tell();
+ aFileStream.Seek(STREAM_SEEK_TO_BEGIN);
+ OStringBuffer aDocument(nSize);
+
+ char cCharacter;
+ for (sal_Size i = 0; i<nSize; ++i)
+ {
+ aFileStream.ReadChar(cCharacter);
+ aDocument.append(cCharacter);
+ }
+
+ return htmlParseDoc((xmlChar*)aDocument.getStr(), NULL);
}
private:
@@ -38,6 +62,11 @@ private:
void preTest(const char* filename) SAL_OVERRIDE
{
+ if (getTestName() == "testExportOfImagesWithSkipImageEnabled")
+ setFilterOptions("SkipImages");
+ else
+ setFilterOptions("");
+
if (OString(filename) == "charborder.odt" && SW_MOD())
{
// FIXME if padding-top gets exported as inches, not cms, we get rounding errors.
@@ -55,19 +84,17 @@ private:
pPref->SetMetric(m_eUnit);
}
}
-
- FieldUnit m_eUnit;
};
-#define DECLARE_HTMLEXPORT_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
+#define DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(TestName, filename) DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, Test)
-DECLARE_HTMLEXPORT_TEST(testFdo62336, "fdo62336.docx")
+DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testFdo62336, "fdo62336.docx")
{
// The problem was essentially a crash during table export as docx/rtf/html
// If either of no-calc-layout or no-test-import is enabled, the crash does not occur
}
-DECLARE_HTMLEXPORT_TEST(testCharacterBorder, "charborder.odt")
+DECLARE_HTMLEXPORT_ROUNDTRIP_TEST(testCharacterBorder, "charborder.odt")
{
uno::Reference<beans::XPropertySet> xRun(getRun(getParagraph(1),1), uno::UNO_QUERY);
@@ -90,6 +117,28 @@ DECLARE_HTMLEXPORT_TEST(testCharacterBorder, "charborder.odt")
// No shadow
}
+#define DECLARE_HTMLEXPORT_TEST(TestName, filename) DECLARE_SW_EXPORT_TEST(TestName, filename, Test)
+
+DECLARE_HTMLEXPORT_TEST(testExportOfImages, "textAndImage.docx")
+{
+ htmlDocPtr pDoc = parseHtml();
+ if (pDoc)
+ {
+ assertXPath(pDoc, "/html/body", 1);
+ assertXPath(pDoc, "/html/body/p/img", 1);
+ }
+}
+
+DECLARE_HTMLEXPORT_TEST(testExportOfImagesWithSkipImageEnabled, "textAndImage.docx")
+{
+ htmlDocPtr pDoc = parseHtml();
+ if (pDoc)
+ {
+ assertXPath(pDoc, "/html/body", 1);
+ assertXPath(pDoc, "/html/body/p/img", 0);
+ }
+}
+
#endif
CPPUNIT_PLUGIN_IMPLEMENT();
commit b2d6ca342cf98685390e4d7354dcb61de40ee8b7
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Tue Apr 8 08:46:43 2014 +0200
sw test: add export test macro, remember test name
Added a new export only macro - this can be used to create tests
which import a document (in any format), and export it in a format
that is being tested. The exported document isn't loaded again, but
it must be asserted using xpath. The primary usage of this is to
test the HTML export.
Change-Id: I1ad300f6274a2181f7f29fed3903b99b68f37fd9
diff --git a/sw/qa/extras/inc/swmodeltestbase.hxx b/sw/qa/extras/inc/swmodeltestbase.hxx
index 9b3faf8..d133d73 100644
--- a/sw/qa/extras/inc/swmodeltestbase.hxx
+++ b/sw/qa/extras/inc/swmodeltestbase.hxx
@@ -28,6 +28,7 @@
#include <rtl/ustrbuf.hxx>
#include <comphelper/processfactory.hxx>
#include <unotools/tempfile.hxx>
+#include <unotools/mediadescriptor.hxx>
#include <unotxdoc.hxx>
#include <docsh.hxx>
@@ -39,7 +40,7 @@
#include <libxml/xpathInternals.h>
#include <libxml/parserInternals.h>
-using namespace com::sun::star;
+using namespace css;
#define DEFAULT_STYLE "Default Style"
#define EMU_TO_MM100(EMU) (EMU / 360)
@@ -58,6 +59,8 @@ using namespace com::sun::star;
*/
#define DECLARE_SW_ROUNDTRIP_TEST(TestName, filename, BaseClass) \
class TestName : public BaseClass { \
+ protected:\
+ virtual OUString getTestName() { return OUString::createFromAscii(#TestName); }\
public:\
CPPUNIT_TEST_SUITE(TestName); \
CPPUNIT_TEST(Import); \
@@ -77,6 +80,8 @@ using namespace com::sun::star;
#define DECLARE_SW_IMPORT_TEST(TestName, filename, BaseClass) \
class TestName : public BaseClass { \
+ protected:\
+ virtual OUString getTestName() { return OUString::createFromAscii(#TestName); }\
public:\
CPPUNIT_TEST_SUITE(TestName); \
CPPUNIT_TEST(Import); \
@@ -90,22 +95,50 @@ using namespace com::sun::star;
CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
void TestName::verify()
+#define DECLARE_SW_EXPORT_TEST(TestName, filename, BaseClass) \
+ class TestName : public BaseClass { \
+ protected:\
+ virtual OUString getTestName() { return OUString::createFromAscii(#TestName); }\
+ public:\
+ CPPUNIT_TEST_SUITE(TestName); \
+ CPPUNIT_TEST(Import_Export); \
+ CPPUNIT_TEST_SUITE_END(); \
+ \
+ void Import_Export() {\
+ executeImportExport(filename);\
+ }\
+ void verify() SAL_OVERRIDE;\
+ }; \
+ CPPUNIT_TEST_SUITE_REGISTRATION(TestName); \
+ void TestName::verify()
+
/// Base class for filter tests loading or roundtriping a document, then asserting the document model.
class SwModelTestBase : public test::BootstrapFixture, public unotest::MacrosTest
{
+ OUString maFilterOptions;
+protected:
+ virtual OUString getTestName() { return OUString(); }
+
public:
+ OUString& getFilterOptions()
+ {
+ return maFilterOptions;
+ }
+ void setFilterOptions(OUString rFilterOptions)
+ {
+ maFilterOptions = rFilterOptions;
+ }
+
SwModelTestBase(const char* pTestDocumentPath = "", const char* pFilter = "")
: mpXmlBuffer(0),
mpTestDocumentPath(pTestDocumentPath),
mpFilter(pFilter),
m_nStartTime(0),
m_bExported(false)
- {
- }
+ {}
virtual ~SwModelTestBase()
- {
- }
+ {}
virtual void setUp() SAL_OVERRIDE
{
@@ -158,6 +191,23 @@ protected:
}
/**
+ * Helper func used by each unit test to test the 'export' code.
+ * (Loads the requested file for document base (this represents
+ * the initial document condition), exports with the desired
+ * export filter and then calls 'verify' method)
+ */
+ void executeImportExport(const char* filename)
+ {
+ header();
+ preTest(filename);
+ load(mpTestDocumentPath, filename);
+ save(OUString::createFromAscii(mpFilter), m_aTempFile);
+ postTest(filename);
+ verify();
+ finish();
+ }
+
+ /**
* Function overloaded by unit test. See DECLARE_SW_*_TEST macros
*/
virtual void verify()
@@ -443,12 +493,13 @@ protected:
void reload(const char* pFilter, const char* filename)
{
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aArgs(1);
- aArgs[0].Name = "FilterName";
OUString aFilterName = OUString::createFromAscii(pFilter);
- aArgs[0].Value <<= aFilterName;
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= aFilterName;
+ if (!maFilterOptions.isEmpty())
+ aMediaDescriptor["FilterOptions"] <<= maFilterOptions;
m_aTempFile.EnableKillingFile();
- xStorable->storeToURL(m_aTempFile.GetURL(), aArgs);
+ xStorable->storeToURL(m_aTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
uno::Reference<lang::XComponent> xComponent(xStorable, uno::UNO_QUERY);
xComponent->dispose();
m_bExported = true;
@@ -474,14 +525,15 @@ protected:
}
/// Save the loaded document to a tempfile. Can be used to check the resulting docx/odt directly as a ZIP file.
- void save(const OUString& aFilter, utl::TempFile& rTempFile)
+ void save(const OUString& aFilterName, utl::TempFile& rTempFile)
{
rTempFile.EnableKillingFile();
uno::Reference<frame::XStorable> xStorable(mxComponent, uno::UNO_QUERY);
- uno::Sequence<beans::PropertyValue> aFilterArgs(1);
- aFilterArgs[0].Name = "FilterName";
- aFilterArgs[0].Value <<= aFilter;
- xStorable->storeToURL(rTempFile.GetURL(), aFilterArgs);
+ utl::MediaDescriptor aMediaDescriptor;
+ aMediaDescriptor["FilterName"] <<= aFilterName;
+ if (!maFilterOptions.isEmpty())
+ aMediaDescriptor["FilterOptions"] <<= maFilterOptions;
+ xStorable->storeToURL(rTempFile.GetURL(), aMediaDescriptor.getAsConstPropertyValueList());
}
void finish()
commit 2387805ffc4860046de57b154a51bc2354484bcd
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Apr 6 12:34:41 2014 +0200
html: rename IgnoreImages -> SkipImages, initialize to false
Change-Id: I663264adab001bd1916b13c0d7c75f8a693687d4
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index 604b210..451e35e 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -109,6 +109,7 @@ SwHTMLWriter::SwHTMLWriter( const OUString& rBaseURL )
, bLFPossible( sal_False )
, bPreserveForm( sal_False )
, bCfgNetscape4( sal_False )
+ , mbSkipImages(false)
{
SetBaseURL( rBaseURL );
@@ -143,7 +144,7 @@ void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
OUString sFilterOptions = ((const SfxStringItem*)pItem)->GetValue();
- if (sFilterOptions == "IgnoreImages")
+ if (sFilterOptions == "SkipImages")
{
mbSkipImages = true;
}
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 2e7508e..7d4b310 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -394,7 +394,7 @@ public:
sal_Bool bCfgNetscape4 : 1; // Netscape4 Hacks
- sal_Bool mbSkipImages : 1;
+ bool mbSkipImages : 1;
// 23
commit 7f63706ad64ed781f8c3cdeeb28a44a3c31f432c
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Apr 6 12:17:23 2014 +0200
liblo: extend doc_saveAs with filterOptions
Change-Id: I720f2819955b6f26ea7161493cccb07f873f2a51
diff --git a/desktop/inc/liblibreoffice.h b/desktop/inc/liblibreoffice.h
index 37920ce..e9df566 100644
--- a/desktop/inc/liblibreoffice.h
+++ b/desktop/inc/liblibreoffice.h
@@ -35,7 +35,8 @@ struct _LibreOfficeDocument
void (*destroy) (LibreOfficeDocument* pThis);
int (*saveAs) (LibreOfficeDocument* pThis,
const char *pUrl,
- const char *pFormat);
+ const char *pFormat,
+ const char *pFilterOptions);
};
LibreOffice* lo_init (const char* pInstallPath);
diff --git a/desktop/inc/liblibreoffice.hxx b/desktop/inc/liblibreoffice.hxx
index 9076992..ef01cb3 100644
--- a/desktop/inc/liblibreoffice.hxx
+++ b/desktop/inc/liblibreoffice.hxx
@@ -35,9 +35,9 @@ public:
}
// Save as the given format, if format is NULL sniff from ext'n
- inline bool saveAs(const char* pUrl, const char* pFormat = NULL)
+ inline bool saveAs(const char* pUrl, const char* pFormat = NULL, const char* pFilterOptions = NULL)
{
- return mpDoc->saveAs(mpDoc, pUrl, pFormat);
+ return mpDoc->saveAs(mpDoc, pUrl, pFormat, pFilterOptions);
}
};
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 2b49673..9703699 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -129,7 +129,7 @@ extern "C"
SAL_DLLPUBLIC_EXPORT LibreOffice *liblibreoffice_hook(void);
static void doc_destroy(LibreOfficeDocument* pThis);
-static int doc_saveAs(LibreOfficeDocument* pThis, const char* pUrl, const char* pFormat);
+static int doc_saveAs(LibreOfficeDocument* pThis, const char* pUrl, const char* pFormat, const char* pFilterOptions);
struct LibLODocument_Impl : public _LibreOfficeDocument
{
@@ -207,7 +207,7 @@ static LibreOfficeDocument* lo_documentLoad(LibreOffice* pThis, const char* pURL
return NULL;
}
-static int doc_saveAs(LibreOfficeDocument* pThis, const char* sUrl, const char* pFormat)
+static int doc_saveAs(LibreOfficeDocument* pThis, const char* sUrl, const char* pFormat, const char* pFilterOptions)
{
LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
@@ -268,9 +268,12 @@ static int doc_saveAs(LibreOfficeDocument* pThis, const char* sUrl, const char*
return false;
}
+ OUString aFilterOptions = getUString(pFilterOptions);
+
MediaDescriptor aSaveMediaDescriptor;
aSaveMediaDescriptor["Overwrite"] <<= sal_True;
aSaveMediaDescriptor["FilterName"] <<= aFilterName;
+ aSaveMediaDescriptor[MediaDescriptor::PROP_FILTEROPTIONS()] <<= aFilterOptions;
uno::Reference<frame::XStorable> xStorable(pDocument->mxComponent, uno::UNO_QUERY_THROW);
xStorable->storeToURL(aURL, aSaveMediaDescriptor.getAsConstPropertyValueList());
commit e50699e6b85781a6dfdede703bb6012466fc4b93
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sun Apr 6 12:05:13 2014 +0200
liblo: clean-up liblibreoffice.h(xx)
Change-Id: I596fc3afde94e095ecf97c23617158f3d49afcc1
diff --git a/desktop/inc/liblibreoffice.h b/desktop/inc/liblibreoffice.h
index db3b835..37920ce 100644
--- a/desktop/inc/liblibreoffice.h
+++ b/desktop/inc/liblibreoffice.h
@@ -11,32 +11,34 @@
#define INCLUDED_DESKTOP_INC_LIBLIBREOFFICE_H
#ifdef __cplusplus
- extern "C" {
+extern "C"
+{
#endif
typedef struct _LibreOffice LibreOffice;
typedef struct _LibreOfficeDocument LibreOfficeDocument;
-struct _LibreOffice {
+struct _LibreOffice
+{
int nSize;
void (*destroy) (LibreOffice *pThis);
- int (*initialize) (LibreOffice *pThis,
- const char *pInstallPath);
- LibreOfficeDocument *(*documentLoad) (LibreOffice *pThis,
- const char *pURL);
- char * (*getError) (LibreOffice *pThis);
+ int (*initialize) (LibreOffice *pThis, const char *pInstallPath);
+ LibreOfficeDocument* (*documentLoad) (LibreOffice *pThis, const char *pURL);
+ char* (*getError) (LibreOffice *pThis);
};
-struct _LibreOfficeDocument {
+struct _LibreOfficeDocument
+{
int nSize;
- void (*destroy) (LibreOfficeDocument *pThis);
- int (*saveAs) (LibreOfficeDocument *pThis,
- const char *pUrl, const char *pFormat);
+ void (*destroy) (LibreOfficeDocument* pThis);
+ int (*saveAs) (LibreOfficeDocument* pThis,
+ const char *pUrl,
+ const char *pFormat);
};
-LibreOffice *lo_init (const char *install_path);
+LibreOffice* lo_init (const char* pInstallPath);
#ifdef __cplusplus
}
diff --git a/desktop/inc/liblibreoffice.hxx b/desktop/inc/liblibreoffice.hxx
index 9cac41b..9076992 100644
--- a/desktop/inc/liblibreoffice.hxx
+++ b/desktop/inc/liblibreoffice.hxx
@@ -21,48 +21,67 @@
class LODocument
{
- LibreOfficeDocument *mpDoc;
+private:
+ LibreOfficeDocument* mpDoc;
+
public:
- inline LODocument( LibreOfficeDocument *pDoc ) : mpDoc( pDoc ) {}
- inline ~LODocument() { mpDoc->destroy( mpDoc ); }
+ inline LODocument(LibreOfficeDocument* pDoc) :
+ mpDoc(pDoc)
+ {}
+
+ inline ~LODocument()
+ {
+ mpDoc->destroy(mpDoc);
+ }
// Save as the given format, if format is NULL sniff from ext'n
- inline bool saveAs( const char *url, const char *format = NULL )
+ inline bool saveAs(const char* pUrl, const char* pFormat = NULL)
{
- return mpDoc->saveAs( mpDoc, url, format );
+ return mpDoc->saveAs(mpDoc, pUrl, pFormat);
}
};
class LibLibreOffice
{
- LibreOffice *mpThis;
+private:
+ LibreOffice* mpThis;
+
public:
- inline LibLibreOffice( LibreOffice *pThis ) : mpThis( pThis ) {}
- inline ~LibLibreOffice() { mpThis->destroy( mpThis ); };
+ inline LibLibreOffice(LibreOffice* pThis) :
+ mpThis(pThis)
+ {}
- inline bool initialize( const char *installPath )
+ inline ~LibLibreOffice()
{
- return mpThis->initialize( mpThis, installPath );
+ mpThis->destroy(mpThis);
}
- inline LODocument *documentLoad( const char *url )
+ inline bool initialize(const char* pInstallPath)
{
- LibreOfficeDocument *pDoc = mpThis->documentLoad( mpThis, url );
- if( !pDoc )
+ return mpThis->initialize(mpThis, pInstallPath);
+ }
+
+ inline LODocument* documentLoad(const char* pUrl)
+ {
+ LibreOfficeDocument* pDoc = mpThis->documentLoad(mpThis, pUrl);
+ if (pDoc == NULL)
return NULL;
- return new LODocument( pDoc );
+ return new LODocument(pDoc);
}
// return the last error as a string, free me.
- inline char *getError() { return mpThis->getError( mpThis ); }
+ inline char* getError()
+ {
+ return mpThis->getError(mpThis);
+ }
};
-inline LibLibreOffice *lo_cpp_init( const char *install_path )
+inline LibLibreOffice* lo_cpp_init(const char* pInstallPath)
{
- LibreOffice *pThis = lo_init( install_path );
- if( !pThis || pThis->nSize == 0 )
+ LibreOffice* pThis = lo_init(pInstallPath);
+ if (pThis == NULL || pThis->nSize == 0)
return NULL;
- return new LibLibreOffice( pThis );
+ return new LibLibreOffice(pThis);
}
#endif
commit 4aec6c9e3c0f51a6c2476295117d10cd5151d7b2
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Apr 5 23:36:23 2014 +0200
html: "IgnoreImages" Option, which ignores images at export
Change-Id: I7ff6e83fabbc9f58e16b2617207a37e8dd0061d9
diff --git a/sw/source/filter/html/htmlflywriter.cxx b/sw/source/filter/html/htmlflywriter.cxx
index 3f0b14a..6060530 100644
--- a/sw/source/filter/html/htmlflywriter.cxx
+++ b/sw/source/filter/html/htmlflywriter.cxx
@@ -811,6 +811,9 @@ Writer& OutHTML_Image( Writer& rWrt, const SwFrmFmt &rFrmFmt,
{
SwHTMLWriter & rHTMLWrt = (SwHTMLWriter&)rWrt;
+ if (rHTMLWrt.mbSkipImages)
+ return rHTMLWrt;
+
// ggf. ein noch offenes Attribut voruebergehend beenden
if( !rHTMLWrt.aINetFmts.empty() )
{
diff --git a/sw/source/filter/html/wrthtml.cxx b/sw/source/filter/html/wrthtml.cxx
index bf8dac6..604b210 100644
--- a/sw/source/filter/html/wrthtml.cxx
+++ b/sw/source/filter/html/wrthtml.cxx
@@ -80,6 +80,8 @@
#define MAX_INDENT_LEVEL 20
+using namespace css;
+
static sal_Char sIndentTabs[MAX_INDENT_LEVEL+2] =
"\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t";
@@ -129,6 +131,24 @@ SwHTMLWriter::~SwHTMLWriter()
delete pNumRuleInfo;
}
+void SwHTMLWriter::SetupFilterOptions(SfxMedium& rMedium)
+{
+ const SfxItemSet* pSet = rMedium.GetItemSet();
+ if (pSet == NULL)
+ return;
+
+ const SfxPoolItem* pItem;
+ if (pSet->GetItemState( SID_FILE_FILTEROPTIONS, true, &pItem ) != SFX_ITEM_SET)
+ return;
+
+
+ OUString sFilterOptions = ((const SfxStringItem*)pItem)->GetValue();
+ if (sFilterOptions == "IgnoreImages")
+ {
+ mbSkipImages = true;
+ }
+}
+
sal_uLong SwHTMLWriter::WriteStream()
{
SvxHtmlOptions& rHtmlOptions = SvxHtmlOptions::Get();
@@ -893,7 +913,7 @@ const SwPageDesc *SwHTMLWriter::MakeHeader( sal_uInt16 &rHeaderAttrs )
// DokumentInfo
OString sIndent = GetIndentString();
- using namespace ::com::sun::star;
+
uno::Reference<document::XDocumentProperties> xDocProps;
SwDocShell *pDocShell(pDoc->GetDocShell());
if (pDocShell)
diff --git a/sw/source/filter/html/wrthtml.hxx b/sw/source/filter/html/wrthtml.hxx
index 79b8fb9..2e7508e 100644
--- a/sw/source/filter/html/wrthtml.hxx
+++ b/sw/source/filter/html/wrthtml.hxx
@@ -281,6 +281,7 @@ class SwHTMLWriter : public Writer
protected:
sal_uLong WriteStream() SAL_OVERRIDE;
+ void SetupFilterOptions(SfxMedium& rMedium) SAL_OVERRIDE;
public:
std::vector<OUString> aImgMapNames; // geschriebene Image Maps
@@ -392,6 +393,9 @@ public:
sal_Bool bPreserveForm : 1; // die aktuelle Form beibehalten
sal_Bool bCfgNetscape4 : 1; // Netscape4 Hacks
+
+ sal_Bool mbSkipImages : 1;
+
// 23
SwHTMLWriter( const OUString& rBaseURL );
commit 5f230bcea7da479931653a75719282de923eed9d
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Apr 5 23:34:53 2014 +0200
sw: SetupFilterOptions for any Writer derived filter (html, ascii)
Change-Id: I6f0147ea640a7ad767e2c0112b5e18dcb530fa7c
diff --git a/sw/inc/shellio.hxx b/sw/inc/shellio.hxx
index bdb3aea..0f2ff19 100644
--- a/sw/inc/shellio.hxx
+++ b/sw/inc/shellio.hxx
@@ -421,6 +421,8 @@ public:
virtual sal_uLong Write( SwPaM&, const com::sun::star::uno::Reference < com::sun::star::embed::XStorage >&, const OUString* = 0, SfxMedium* = 0 );
virtual sal_uLong Write( SwPaM&, SotStorage&, const OUString* = 0 );
+ virtual void SetupFilterOptions(SfxMedium& rMedium);
+
virtual void SetVersion( const OUString&, long );
virtual sal_Bool IsStgWriter() const;
diff --git a/sw/source/filter/writer/writer.cxx b/sw/source/filter/writer/writer.cxx
index aafa161..c51975b 100644
--- a/sw/source/filter/writer/writer.cxx
+++ b/sw/source/filter/writer/writer.cxx
@@ -32,7 +32,7 @@
#include <numrule.hxx>
#include <swerror.h>
-using namespace ::com::sun::star;
+using namespace css;
namespace
{
@@ -267,11 +267,15 @@ sal_uLong Writer::Write( SwPaM& rPaM, SvStream& rStrm, const OUString* pFName )
return nRet;
}
-sal_uLong Writer::Write( SwPaM& rPam, SfxMedium& rMed, const OUString* pFileName )
+void Writer::SetupFilterOptions(SfxMedium& /*rMedium*/)
+{}
+
+sal_uLong Writer::Write( SwPaM& rPam, SfxMedium& rMedium, const OUString* pFileName )
{
+ SetupFilterOptions(rMedium);
// This method must be overloaded in SwXMLWriter a storage from medium will be used there.
// The microsoft format can write to storage but the storage will be based on the stream.
- return Write( rPam, *rMed.GetOutStream(), pFileName );
+ return Write( rPam, *rMedium.GetOutStream(), pFileName );
}
sal_uLong Writer::Write( SwPaM& /*rPam*/, SvStorage&, const OUString* )
commit 66800ce1b5fac4bcb4a67aede96e7558dd982303
Author: Tomaž Vajngerl <tomaz.vajngerl at collabora.com>
Date: Sat Apr 5 21:48:47 2014 +0200
liblo: use MediaDescriptor / clean-up
Change-Id: If70519066081d8e2c8ed24771369d4afef336896
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 9f65dd7..2b49673 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -37,21 +37,24 @@
#include <tools/resmgr.hxx>
#include <vcl/graphicfilter.hxx>
#include <unotools/syslocaleoptions.hxx>
+#include <unotools/mediadescriptor.hxx>
-using namespace ::com::sun::star;
+using namespace css;
+using namespace utl;
struct LibLODocument_Impl;
struct LibLibreOffice_Impl;
static LibLibreOffice_Impl *gImpl = NULL;
-typedef struct {
+typedef struct
+{
const char *extn;
const char *filterName;
} ExtensionMap;
-static const ExtensionMap
-aWriterExtensionMap[] = {
+static const ExtensionMap aWriterExtensionMap[] =
+{
{ "doc", "MS Word 97" },
{ "docx", "MS Word 2007 XML" },
{ "fodt", "OpenDocument Text Flat XML" },
@@ -64,8 +67,8 @@ aWriterExtensionMap[] = {
{ NULL, NULL }
};
-static const ExtensionMap
-aCalcExtensionMap[] = {
+static const ExtensionMap aCalcExtensionMap[] =
+{
{ "csv", "Text - txt - csv (StarCalc)" },
{ "fods", "OpenDocument Spreadsheet Flat XML" },
{ "html", "HTML (StarCalc)" },
@@ -78,8 +81,8 @@ aCalcExtensionMap[] = {
{ NULL, NULL }
};
-static const ExtensionMap
-aImpressExtensionMap[] = {
+static const ExtensionMap aImpressExtensionMap[] =
+{
{ "fodp", "OpenDocument Presentation Flat XML" },
{ "html", "impress_html_Export" },
{ "odg", "impress8_draw" },
@@ -97,16 +100,17 @@ aImpressExtensionMap[] = {
{ NULL, NULL }
};
-static OUString getUString( const char *str )
+static OUString getUString(const char* pString)
{
- if( !str )
- return OUString( "" );
- return OStringToOUString( OString( str, strlen (str) ),
- RTL_TEXTENCODING_UTF8 );
+ if (pString == NULL)
+ return OUString();
+
+ OString sString(pString, strlen(pString));
+ return OStringToOUString(sString, RTL_TEXTENCODING_UTF8);
}
// Try to convert a relative URL to an absolute one
-static OUString getAbsoluteURL( const char *pURL )
+static OUString getAbsoluteURL(const char* pURL)
{
OUString aURL( getUString( pURL ) );
OUString sAbsoluteDocUrl, sWorkingDir, sDocPathUrl;
@@ -119,47 +123,46 @@ static OUString getAbsoluteURL( const char *pURL )
return sAbsoluteDocUrl;
}
-extern "C" {
+extern "C"
+{
SAL_DLLPUBLIC_EXPORT LibreOffice *liblibreoffice_hook(void);
-static void doc_destroy( LibreOfficeDocument *pThis );
-static int doc_saveAs( LibreOfficeDocument *pThis, const char *pUrl, const char *pFormat );
+static void doc_destroy(LibreOfficeDocument* pThis);
+static int doc_saveAs(LibreOfficeDocument* pThis, const char* pUrl, const char* pFormat);
struct LibLODocument_Impl : public _LibreOfficeDocument
{
- uno::Reference < css::lang::XComponent > mxComponent;
+ uno::Reference<css::lang::XComponent> mxComponent;
- LibLODocument_Impl( const uno::Reference < css::lang::XComponent > &xComponent )
- : mxComponent( xComponent )
+ LibLODocument_Impl(const uno::Reference <css::lang::XComponent> &xComponent) :
+ mxComponent( xComponent )
{
- nSize = sizeof( LibreOffice );
+ nSize = sizeof(LibreOffice);
destroy = doc_destroy;
saveAs = doc_saveAs;
}
};
-static void doc_destroy( LibreOfficeDocument *pThis )
+static void doc_destroy(LibreOfficeDocument *pThis)
{
- LibLODocument_Impl *pDocument = static_cast< LibLODocument_Impl *>( pThis );
+ LibLODocument_Impl *pDocument = static_cast<LibLODocument_Impl*>(pThis);
delete pDocument;
}
-static void lo_destroy (LibreOffice *pThis);
-static int lo_initialize (LibreOffice *pThis,
- const char *pInstallPath);
-static LibreOfficeDocument *lo_documentLoad (LibreOffice *pThis,
- const char *pURL);
-static char * lo_getError (LibreOffice *pThis);
+static void lo_destroy (LibreOffice* pThis);
+static int lo_initialize (LibreOffice* pThis, const char* pInstallPath);
+static LibreOfficeDocument* lo_documentLoad (LibreOffice* pThis, const char* pURL);
+static char * lo_getError (LibreOffice* pThis);
struct LibLibreOffice_Impl : public _LibreOffice
{
- rtl::OUString maLastExceptionMsg;
+ OUString maLastExceptionMsg;
LibLibreOffice_Impl()
{
- nSize = sizeof( LibreOfficeDocument );
+ nSize = sizeof(LibreOfficeDocument);
destroy = lo_destroy;
initialize = lo_initialize;
@@ -173,62 +176,60 @@ static uno::Reference<css::uno::XComponentContext> xContext;
static uno::Reference<css::lang::XMultiServiceFactory> xSFactory;
static uno::Reference<css::lang::XMultiComponentFactory> xFactory;
-static LibreOfficeDocument *
-lo_documentLoad( LibreOffice *pThis, const char *pURL )
+static LibreOfficeDocument* lo_documentLoad(LibreOffice* pThis, const char* pURL)
{
- LibLibreOffice_Impl *pLib = static_cast< LibLibreOffice_Impl *>( pThis );
+ LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
- OUString aURL = getAbsoluteURL( pURL );
+ OUString aURL = getAbsoluteURL(pURL);
- uno::Reference < css::frame::XDesktop2 > xComponentLoader =
- css::frame::Desktop::create(xContext);
+ uno::Reference<frame::XDesktop2> xComponentLoader = frame::Desktop::create(xContext);
pLib->maLastExceptionMsg = "";
- try {
- uno::Reference < css::lang::XComponent > xComponent =
- xComponentLoader->loadComponentFromURL(
- aURL, OUString("_blank"), 0,
- uno::Sequence < css::beans::PropertyValue >());
- if( xComponentLoader.is() )
- return new LibLODocument_Impl( xComponent );
+
+ try
+ {
+ uno::Reference<lang::XComponent> xComponent;
+ xComponent = xComponentLoader->loadComponentFromURL(
+ aURL, OUString("_blank"), 0,
+ uno::Sequence<css::beans::PropertyValue>());
+
+ if (xComponentLoader.is())
+ return new LibLODocument_Impl(xComponent);
else
pLib->maLastExceptionMsg = "unknown load failure";
- } catch (const uno::Exception &ex) {
- pLib->maLastExceptionMsg = ex.Message;
+
+ }
+ catch (const uno::Exception& exception)
+ {
+ pLib->maLastExceptionMsg = exception.Message;
}
+
return NULL;
}
-static int
-doc_saveAs( LibreOfficeDocument *pThis,
- const char *url, const char *format )
+static int doc_saveAs(LibreOfficeDocument* pThis, const char* sUrl, const char* pFormat)
{
- LibLODocument_Impl *pDocument = static_cast< LibLODocument_Impl *>( pThis );
-
- OUString sFormat = getUString( format );
+ LibLODocument_Impl* pDocument = static_cast<LibLODocument_Impl*>(pThis);
- OUString aURL = getAbsoluteURL( url );
+ OUString sFormat = getUString(pFormat);
+ OUString aURL = getAbsoluteURL(sUrl);
- try {
- uno::Reference< frame::XModel > xDocument( pDocument->mxComponent,
- uno::UNO_QUERY_THROW );
- uno::Sequence< beans::PropertyValue > aSeq = xDocument->getArgs();
+ try
+ {
+ uno::Reference<frame::XModel> xDocument(pDocument->mxComponent, uno::UNO_QUERY_THROW);
+ uno::Sequence<beans::PropertyValue> aSequence = xDocument->getArgs();
- OUString aDocumentService;
- for( sal_Int32 i = 0; i < aSeq.getLength(); ++i )
- {
- if( aSeq[i].Name == "DocumentService" )
- aSeq[i].Value >>= aDocumentService;
- OUString aValue;
- aSeq[i].Value >>= aValue;
- }
+ MediaDescriptor aMediaDescriptor(aSequence);
+ OUString sPropertyName = MediaDescriptor::PROP_DOCUMENTSERVICE();
+ OUString aDocumentService = aMediaDescriptor.getUnpackedValueOrDefault(sPropertyName, OUString());
- if( aDocumentService == "")
+ if (aDocumentService.isEmpty())
{
gImpl->maLastExceptionMsg = "Unknown document type";
return false;
}
- const ExtensionMap *pMap;
+
+ const ExtensionMap* pMap;
if( aDocumentService == "com.sun.star.sheet.SpreadsheetDocument" )
pMap = (const ExtensionMap *)aCalcExtensionMap;
@@ -237,10 +238,10 @@ doc_saveAs( LibreOfficeDocument *pThis,
else // for the sake of argument only writer documents ...
pMap = (const ExtensionMap *)aWriterExtensionMap;
- if( ! format )
+ if (pFormat == NULL)
{
// sniff from the extension
- sal_Int32 idx = aURL.lastIndexOf( "." );
+ sal_Int32 idx = aURL.lastIndexOf(".");
if( idx > 0 )
{
sFormat = aURL.copy( idx + 1 );
@@ -253,71 +254,67 @@ doc_saveAs( LibreOfficeDocument *pThis,
}
OUString aFilterName;
- for( sal_Int32 i = 0; pMap[i].extn; i++ )
+ for (sal_Int32 i = 0; pMap[i].extn; ++i)
{
- if( sFormat.equalsIgnoreAsciiCaseAscii( pMap[i].extn ) )
+ if (sFormat.equalsIgnoreAsciiCaseAscii(pMap[i].extn))
{
- aFilterName = getUString( pMap[i].filterName );
+ aFilterName = getUString(pMap[i].filterName);
break;
}
}
- if( ! aFilterName.getLength() )
+ if (aFilterName.isEmpty())
{
gImpl->maLastExceptionMsg = "no output filter found for provided suffix";
return false;
}
- aSeq.realloc(2);
- aSeq[0].Name = "Overwrite";
- aSeq[0].Value <<= sal_True;
- aSeq[1].Name = "FilterName";
- aSeq[1].Value <<= aFilterName;
+ MediaDescriptor aSaveMediaDescriptor;
+ aSaveMediaDescriptor["Overwrite"] <<= sal_True;
+ aSaveMediaDescriptor["FilterName"] <<= aFilterName;
- uno::Reference< frame::XStorable > xStorable( pDocument->mxComponent,
- uno::UNO_QUERY_THROW );
- xStorable->storeToURL( aURL, aSeq );
+ uno::Reference<frame::XStorable> xStorable(pDocument->mxComponent, uno::UNO_QUERY_THROW);
+ xStorable->storeToURL(aURL, aSaveMediaDescriptor.getAsConstPropertyValueList());
return true;
- } catch (const uno::Exception &ex) {
- gImpl->maLastExceptionMsg = "exception " + ex.Message;
- return false;
}
+ catch (const uno::Exception& exception)
+ {
+ gImpl->maLastExceptionMsg = "exception: " + exception.Message;
+ }
+ return false;
}
-static char *
-lo_getError (LibreOffice *pThis)
+static char* lo_getError (LibreOffice *pThis)
{
- LibLibreOffice_Impl *pLib = static_cast< LibLibreOffice_Impl *>( pThis );
- OString aStr = rtl::OUStringToOString( pLib->maLastExceptionMsg, RTL_TEXTENCODING_UTF8 );
- char *pMem = (char *) malloc (aStr.getLength() + 1);
- strcpy( pMem, aStr.getStr() );
- return pMem;
+ LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
+ OString aString = OUStringToOString(pLib->maLastExceptionMsg, RTL_TEXTENCODING_UTF8);
+ char* pMemory = (char*) malloc(aString.getLength() + 1);
+ strcpy(pMemory, aString.getStr());
+ return pMemory;
}
-static void
-force_c_locale( void )
+static void force_c_locale(void)
{
// force locale (and resource files loaded) to en-US
- OUString aLangISO( "en-US" );
- LanguageTag aLocale( aLangISO );
- ResMgr::SetDefaultLocale( aLocale );
+ OUString aLangISO("en-US");
+ LanguageTag aLocale(aLangISO);
+ ResMgr::SetDefaultLocale(aLocale);
SvtSysLocaleOptions aLocalOptions;
- aLocalOptions.SetLocaleConfigString( aLangISO );
- aLocalOptions.SetUILocaleConfigString( aLangISO );
+ aLocalOptions.SetLocaleConfigString(aLangISO);
+ aLocalOptions.SetUILocaleConfigString(aLangISO);
}
-static void
-aBasicErrorFunc( const OUString &rErr, const OUString &rAction )
+static void aBasicErrorFunc(const OUString& rError, const OUString& rAction)
{
- OStringBuffer aErr( "Unexpected dialog: " );
- aErr.append( OUStringToOString( rAction, RTL_TEXTENCODING_ASCII_US ) );
- aErr.append( " Error: " );
- aErr.append( OUStringToOString( rErr, RTL_TEXTENCODING_ASCII_US ) );
- fprintf( stderr, "Unexpected basic error dialog '%s'\n", aErr.getStr() );
+ OStringBuffer aBuffer("Unexpected dialog: ");
+ aBuffer.append(OUStringToOString(rAction, RTL_TEXTENCODING_ASCII_US));
+ aBuffer.append(" Error: ");
+ aBuffer.append(OUStringToOString(rError, RTL_TEXTENCODING_ASCII_US));
+
+ fprintf(stderr, "Unexpected basic error dialog '%s'\n", aBuffer.getStr());
}
-static void
-initialize_uno( const OUString &aAppURL )
+static void initialize_uno(const OUString &aAppURL)
{
rtl::Bootstrap::setIniFilename( aAppURL + "/fundamentalrc" );
@@ -331,7 +328,7 @@ initialize_uno( const OUString &aAppURL )
);
xContext = cppu::defaultBootstrap_InitialComponentContext();
- fprintf( stderr, "Uno initialized %d\n", xContext.is() );
+ fprintf(stderr, "Uno initialized %d\n", xContext.is());
xFactory = xContext->getServiceManager();
xSFactory = uno::Reference<lang::XMultiServiceFactory>(xFactory, uno::UNO_QUERY_THROW);
comphelper::setProcessServiceFactory(xSFactory);
@@ -342,57 +339,58 @@ initialize_uno( const OUString &aAppURL )
// configmgr setup ?
}
-static int
-lo_initialize( LibreOffice *pThis, const char *app_path )
+static int lo_initialize(LibreOffice* pThis, const char* pAppPath)
{
(void) pThis;
static bool bInitialized = false;
- if( bInitialized )
+ if (bInitialized)
return 1;
- if( !app_path )
+ if (!pAppPath)
return 0;
- OUString aAppPath( app_path, strlen( app_path ), RTL_TEXTENCODING_UTF8 );
+ OUString aAppPath(pAppPath, strlen(pAppPath), RTL_TEXTENCODING_UTF8);
OUString aAppURL;
- if( osl::FileBase::getFileURLFromSystemPath( aAppPath, aAppURL ) !=
- osl::FileBase::E_None )
+ if (osl::FileBase::getFileURLFromSystemPath(aAppPath, aAppURL) != osl::FileBase::E_None)
return 0;
- try {
- initialize_uno( aAppURL );
+ try
+ {
+ initialize_uno(aAppURL);
force_c_locale();
// Force headless
- rtl::Bootstrap::set( "SAL_USE_VCLPLUGIN", "svp" );
+ rtl::Bootstrap::set("SAL_USE_VCLPLUGIN", "svp");
InitVCL();
Application::EnableHeadlessMode(true);
- ErrorHandler::RegisterDisplay( aBasicErrorFunc );
+ ErrorHandler::RegisterDisplay(aBasicErrorFunc);
- fprintf( stderr, "initialized\n" );
+ fprintf(stderr, "initialized\n");
bInitialized = true;
- } catch (css::uno::Exception & e) {
- fprintf( stderr, "bootstrapping exception '%s'\n",
- OUStringToOString( e.Message, RTL_TEXTENCODING_UTF8 ).getStr() );
+ }
+ catch (css::uno::Exception& exception)
+ {
+ fprintf(stderr, "bootstrapping exception '%s'\n",
+ OUStringToOString(exception.Message, RTL_TEXTENCODING_UTF8).getStr());
}
return bInitialized;
}
LibreOffice *liblibreoffice_hook(void)
{
- if( !gImpl )
+ if (!gImpl)
{
- fprintf( stderr, "create libreoffice object\n" );
+ fprintf(stderr, "create libreoffice object\n");
gImpl = new LibLibreOffice_Impl();
}
- return static_cast< LibreOffice *>( gImpl );
+ return static_cast<LibreOffice*>(gImpl);
}
-static void lo_destroy (LibreOffice *pThis)
+static void lo_destroy(LibreOffice *pThis)
{
- LibLibreOffice_Impl *pLib = static_cast< LibLibreOffice_Impl *>( pThis );
+ LibLibreOffice_Impl* pLib = static_cast<LibLibreOffice_Impl*>(pThis);
delete pLib;
gImpl = NULL;
}
More information about the Libreoffice-commits
mailing list