desktop/source/lib/init.cxx | 2 include/unotest/macros_test.hxx | 4 sd/CppunitTest_sd_filters_test.mk | 6 sd/CppunitTest_sd_import_tests.mk | 6 sd/source/filter/html/htmlex.cxx | 202 +++++++++++++++++++++++++++--- sd/source/filter/html/htmlex.hxx | 9 + sd/source/filter/html/htmlpublishmode.hxx | 10 + sd/source/filter/html/sdhtmlfilter.cxx | 7 - unotest/source/cpp/macros_test.cxx | 17 +- 9 files changed, 225 insertions(+), 38 deletions(-)
New commits: commit 272a5e7671fadd254d06d67180f97916891a4cf4 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Sat Apr 12 12:48:22 2014 +0200 sd tests: tab to spaces Change-Id: Icfc9d08b073f76d6c489a8b12a3c27b850a116ce diff --git a/sd/CppunitTest_sd_filters_test.mk b/sd/CppunitTest_sd_filters_test.mk index a2d1562..45c29aa 100644 --- a/sd/CppunitTest_sd_filters_test.mk +++ b/sd/CppunitTest_sd_filters_test.mk @@ -45,15 +45,15 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_filters_test, \ svt \ svx \ svxcore \ - test \ + test \ tl \ tk \ ucbhelper \ - unotest \ + unotest \ utl \ vcl \ xo \ - $(gb_UWINAPI) \ + $(gb_UWINAPI) \ )) $(eval $(call gb_CppunitTest_set_include,sd_filters_test,\ diff --git a/sd/CppunitTest_sd_import_tests.mk b/sd/CppunitTest_sd_import_tests.mk index d1a552f..3661de7 100644 --- a/sd/CppunitTest_sd_import_tests.mk +++ b/sd/CppunitTest_sd_import_tests.mk @@ -40,15 +40,15 @@ $(eval $(call gb_CppunitTest_use_libraries,sd_import_tests, \ svt \ svx \ svxcore \ - test \ + test \ tl \ tk \ ucbhelper \ - unotest \ + unotest \ utl \ vcl \ xo \ - $(gb_UWINAPI) \ + $(gb_UWINAPI) \ )) $(eval $(call gb_CppunitTest_set_include,sd_import_tests,\ commit fa4c74f4d5cb7ff8ae8d4fa43f07c557bcbcf9e0 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Sat Apr 12 12:33:32 2014 +0200 liblo: fix check of xcomponent Change-Id: I8a05a067681767518c688eb836bbe676bed05996 diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx index 183a555..a965be7 100644 --- a/desktop/source/lib/init.cxx +++ b/desktop/source/lib/init.cxx @@ -195,7 +195,7 @@ static LibreOfficeDocument* lo_documentLoad(LibreOffice* pThis, const char* pURL aURL, OUString("_blank"), 0, uno::Sequence<css::beans::PropertyValue>()); - if (xComponentLoader.is()) + if (xComponent.is()) return new LibLODocument_Impl(xComponent); else pLib->maLastExceptionMsg = "unknown load failure"; commit 5830799d5ba3afbb696dc354535fcfd2f10ba059 Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Apr 11 21:31:43 2014 +0200 macros_test: use "css" short form Change-Id: I2e8d8773703df67d090059be8bd9f3c7c7335f78 diff --git a/include/unotest/macros_test.hxx b/include/unotest/macros_test.hxx index d995246..12108ba 100644 --- a/include/unotest/macros_test.hxx +++ b/include/unotest/macros_test.hxx @@ -27,10 +27,10 @@ namespace unotest { class OOO_DLLPUBLIC_UNOTEST MacrosTest { public: - com::sun::star::uno::Reference< com::sun::star::lang::XComponent > loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString() ); + css::uno::Reference< css::lang::XComponent > loadFromDesktop(const OUString& rURL, const OUString& rDocService = OUString() ); protected: - com::sun::star::uno::Reference< com::sun::star::frame::XDesktop2> mxDesktop; + css::uno::Reference< css::frame::XDesktop2> mxDesktop; }; } diff --git a/unotest/source/cpp/macros_test.cxx b/unotest/source/cpp/macros_test.cxx index 9305a68..44f0d56 100644 --- a/unotest/source/cpp/macros_test.cxx +++ b/unotest/source/cpp/macros_test.cxx @@ -15,21 +15,20 @@ #include "cppunit/TestAssert.h" #include <rtl/ustrbuf.hxx> -using namespace com::sun::star; +using namespace css; namespace unotest { -uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(const OUString& rURL, const OUString& rDocService) +uno::Reference<css::lang::XComponent> MacrosTest::loadFromDesktop(const OUString& rURL, const OUString& rDocService) { CPPUNIT_ASSERT_MESSAGE("no desktop", mxDesktop.is()); - uno::Reference< com::sun::star::frame::XComponentLoader> xLoader = uno::Reference< com::sun::star::frame::XComponentLoader >( mxDesktop, uno::UNO_QUERY ); + uno::Reference<frame::XComponentLoader> xLoader = uno::Reference<frame::XComponentLoader>(mxDesktop, uno::UNO_QUERY); CPPUNIT_ASSERT_MESSAGE("no loader", xLoader.is()); - com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue > args(1); + uno::Sequence<beans::PropertyValue> args(1); args[0].Name = "MacroExecutionMode"; args[0].Handle = -1; - args[0].Value <<= - com::sun::star::document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN; - args[0].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; + args[0].Value <<= document::MacroExecMode::ALWAYS_EXECUTE_NO_WARN; + args[0].State = beans::PropertyState_DIRECT_VALUE; if (!rDocService.isEmpty()) { @@ -37,10 +36,10 @@ uno::Reference< com::sun::star::lang::XComponent > MacrosTest::loadFromDesktop(c args[1].Name = "DocumentService"; args[1].Handle = -1; args[1].Value <<= rDocService; - args[1].State = com::sun::star::beans::PropertyState_DIRECT_VALUE; + args[1].State = beans::PropertyState_DIRECT_VALUE; } - uno::Reference< com::sun::star::lang::XComponent> xComponent= xLoader->loadComponentFromURL(rURL, OUString("_default"), 0, args); + uno::Reference<lang::XComponent> xComponent = xLoader->loadComponentFromURL(rURL, OUString("_default"), 0, args); OUString sMessage = "loading failed: " + rURL; CPPUNIT_ASSERT_MESSAGE(OUStringToOString( sMessage, RTL_TEXTENCODING_UTF8 ).getStr( ), xComponent.is()); return xComponent; commit 69fe10662845288c09a05716a93876e2ca95c4bd Author: Tomaž Vajngerl <tomaz.vajng...@collabora.com> Date: Fri Apr 11 14:14:49 2014 +0200 sd html export: "single document" publish mode & support tables Change-Id: I0c9f45011091f962d5304c9efcaebbed7e6c3d9d diff --git a/sd/source/filter/html/htmlex.cxx b/sd/source/filter/html/htmlex.cxx index 16600d1..b06f5b8 100644 --- a/sd/source/filter/html/htmlex.cxx +++ b/sd/source/filter/html/htmlex.cxx @@ -82,6 +82,8 @@ #include "buttonset.hxx" #include <basegfx/polygon/b2dpolygon.hxx> +#include <svx/svdotable.hxx> + using namespace ::com::sun::star; using namespace ::com::sun::star::uno; using namespace ::com::sun::star::beans; @@ -89,6 +91,8 @@ using namespace ::com::sun::star::frame; using namespace ::com::sun::star::lang; using namespace ::com::sun::star::document; +using namespace sdr::table; + // get parameter from Itemset #define RESTOHTML( res ) StringToHTMLString(SD_RESSTR(res)) @@ -312,36 +316,51 @@ OUString HtmlState::SetLink( const OUString& aLink, const OUString& aTarget ) return aStr; } +namespace +{ -// methods of the class HtmlExport -static OUString getParagraphStyle( SdrOutliner* pOutliner, sal_Int32 nPara ) +OUString getParagraphStyle( SdrOutliner* pOutliner, sal_Int32 nPara ) { SfxItemSet aParaSet( pOutliner->GetParaAttribs( nPara ) ); - OUString sStyle("direction:"); + OUString sStyle; + if( static_cast<const SvxFrameDirectionItem*>(aParaSet.GetItem( EE_PARA_WRITINGDIR ))->GetValue() == FRMDIR_HORI_RIGHT_TOP ) { - sStyle += "rtl;"; + + sStyle = "direction: rtl;"; } else { - sStyle += "ltr;"; + // This is the default so don't write it out + // sStyle += "direction: ltr;"; } return sStyle; } +void lclAppendStyle(OUStringBuffer& aBuffer, const OUString& aTag, const OUString& aStyle) +{ + if (aStyle.isEmpty()) + aBuffer.append("<" + aTag + ">"); + else + aBuffer.append("<" + aTag + " style=\"" + aStyle + "\">"); +} + +} // anonymous namespace // constructor for the html export helper classes HtmlExport::HtmlExport( const OUString& aPath, const Sequence< PropertyValue >& rParams, + const OUString& rFilterOptions, SdDrawDocument* pExpDoc, - ::sd::DrawDocShell* pDocShell ) + sd::DrawDocShell* pDocShell ) : maPath( aPath ), + maFilterOptions( rFilterOptions ), mpDoc(pExpDoc), mpDocSh( pDocShell ), meEC(NULL), - meMode( PUBLISH_HTML ), + meMode( PUBLISH_SINGLE_DOCUMENT ), mbContentsPage(false), mnButtonThema(-1), mnWidthPixel( PUB_MEDRES_WIDTH ), @@ -380,6 +399,9 @@ HtmlExport::HtmlExport( case PUBLISH_KIOSK: ExportKiosk(); break; + case PUBLISH_SINGLE_DOCUMENT: + ExportSingleDocument(); + break; } mpDoc->SetChanged(bChange); @@ -616,6 +638,74 @@ void HtmlExport::InitExportParameters( const Sequence< PropertyValue >& rParams maDocFileName = maIndex; } +void HtmlExport::ExportSingleDocument() +{ + SdrOutliner* pOutliner = mpDoc->GetInternalOutliner(); + + maPageNames.resize(mnSdPageCount); + + mnPagesWritten = 0; + InitProgress(mnSdPageCount); + + OUStringBuffer aStr(maHTMLHeader); + aStr.append(CreateMetaCharset()); + aStr.append("</head>\r\n"); + aStr.append(CreateBodyTag()); + + for(sal_uInt16 nSdPage = 0; nSdPage < mnSdPageCount; ++nSdPage) + { + SdPage* pPage = maPages[nSdPage]; + maPageNames[nSdPage] = pPage->GetName(); + + if( mbDocColors ) + { + SetDocColors( pPage ); + } + + // page title + OUString sTitleText(CreateTextForTitle(pOutliner, pPage, pPage->GetPageBackgroundColor())); + OUString sStyle; + + if (nSdPage != 0) // First page - no need for a page brake here + sStyle += "page-break-before:always; "; + sStyle += getParagraphStyle(pOutliner, 0); + + lclAppendStyle(aStr, "h1", sStyle); + + aStr.append(sTitleText); + aStr.append("</h1>\r\n"); + + // write outline text + aStr.append(CreateTextForPage( pOutliner, pPage, true, pPage->GetPageBackgroundColor() )); + + // notes + if(mbNotes) + { + SdPage* pNotesPage = maNotesPages[ nSdPage ]; + OUString aNotesStr( CreateTextForNotesPage( pOutliner, pNotesPage, true, maBackColor) ); + + if (!aNotesStr.isEmpty()) + { + aStr.append("<br>\r\n<h3>"); + aStr.append(RESTOHTML(STR_HTMLEXP_NOTES)); + aStr.append(":</h3>\r\n"); + + aStr.append(aNotesStr); + } + } + + if (mpProgress) + mpProgress->SetState(++mnPagesWritten); + + } + + // close page + aStr.append("</body>\r\n</html>"); + + WriteHtml(maDocFileName, false, aStr.makeStringAndClear()); + + pOutliner->Clear(); +} // exports the (in the c'tor specified impress document) to html void HtmlExport::ExportHtml() @@ -1022,9 +1112,7 @@ bool HtmlExport::CreateHtmlTextForPresPages() // page title OUString sTitleText( CreateTextForTitle(pOutliner,pPage, pPage->GetPageBackgroundColor()) ); - aStr.append("<h1 style=\""); - aStr.append(getParagraphStyle(pOutliner, 0)); - aStr.append("\">"); + lclAppendStyle(aStr, "h1", getParagraphStyle(pOutliner, 0)); aStr.append(sTitleText); aStr.append("</h1>\r\n"); @@ -1123,6 +1211,90 @@ OUString HtmlExport::CreateTextForPage( SdrOutliner* pOutliner, { OUStringBuffer aStr; + for (sal_uInt32 i = 0; i <pPage->GetObjCount(); i++ ) + { + SdrObject* pObject = pPage->GetObj(i); + PresObjKind eKind = pPage->GetPresObjKind(pObject); + + if (eKind == PRESOBJ_TABLE) + { + SdrTableObj* pTableObject = (SdrTableObj*) pObject; + + CellPos aStart, aEnd; + + aStart = pTableObject->getFirstCell(); + aEnd = pTableObject->getLastCell(); + + sal_Int32 nColCount = pTableObject->getColumnCount(); + aStr.append("<table>\r\n"); + for (sal_Int32 nRow = aStart.mnRow; nRow <= aEnd.mnRow; nRow++) + { + aStr.append(" <tr>\r\n"); + for (sal_Int32 nCol = aStart.mnCol; nCol <= aEnd.mnCol; nCol++) + { + aStr.append(" <td>\r\n"); + sal_Int32 nCellIndex = nRow * nColCount + nCol; + SdrText* pText = pTableObject->getText(nCellIndex); + if (!pText || !pText->GetOutlinerParaObject()) + continue; + + pOutliner->SetText(*(pText->GetOutlinerParaObject())); + + sal_Int32 nCount = pOutliner->GetParagraphCount(); + + Paragraph* pPara = NULL; + + sal_Int16 nCurrentDepth = -1; + + for (sal_Int32 nPara = 0; nPara < nCount; nPara++) + { + pPara = pOutliner->GetParagraph(nPara); + if(pPara == 0) + continue; + + const sal_Int16 nDepth = (sal_uInt16) pOutliner->GetDepth(nPara); + OUString aParaText = ParagraphToHTMLString(pOutliner, nPara, rBackgroundColor); + + if (aParaText.isEmpty()) + continue; + + if (nDepth < 0) + { + lclAppendStyle(aStr, "p", getParagraphStyle(pOutliner, nPara)); + aStr.append(aParaText); + aStr.append("</p>\r\n"); + } + else + { + while(nCurrentDepth < nDepth) + { + aStr.append("<ul>\r\n"); + nCurrentDepth++; + } + while(nCurrentDepth > nDepth) + { + aStr.append("</ul>\r\n"); + nCurrentDepth--; + } + lclAppendStyle(aStr, "li", getParagraphStyle(pOutliner, nPara)); + aStr.append(aParaText); + aStr.append("</li>\r\n"); + } + } + while(nCurrentDepth >= 0) + { + aStr.append("</ul>\r\n"); + nCurrentDepth--; + } + pOutliner->Clear(); + aStr.append(" </td>\r\n"); + } + aStr.append(" </tr>\r\n"); + } + aStr.append("</table>\r\n"); + } + } + SdrTextObj* pTO = (SdrTextObj*)pPage->GetPresObj(PRESOBJ_TEXT); if(!pTO) pTO = GetLayoutTextObject(pPage); @@ -1175,7 +1347,7 @@ OUString HtmlExport::CreateTextForPage( SdrOutliner* pOutliner, OUString sStyle(getParagraphStyle(pOutliner, nPara)); if(nActDepth >= 0 ) { - aStr.append("<li style=\"" + sStyle + "\">"); + lclAppendStyle(aStr, "li", sStyle); } if(nActDepth <= 0 && bHeadLine) @@ -1186,7 +1358,7 @@ OUString HtmlExport::CreateTextForPage( SdrOutliner* pOutliner, } else { - aStr.append("<h2 style=\"" + sStyle + "\">"); + lclAppendStyle(aStr, "h2", sStyle); } } aStr.append(aParaText); @@ -1230,7 +1402,7 @@ OUString HtmlExport::CreateTextForNotesPage( SdrOutliner* pOutliner, sal_Int32 nCount = pOutliner->GetParagraphCount(); for (sal_Int32 nPara = 0; nPara < nCount; nPara++) { - aStr.append("<p style=\"" + getParagraphStyle(pOutliner, nPara) + "\">"); + lclAppendStyle(aStr, "p", getParagraphStyle(pOutliner, nPara)); aStr.append(ParagraphToHTMLString(pOutliner, nPara, rBackgroundColor)); aStr.append("</p>\r\n"); } @@ -1958,9 +2130,7 @@ bool HtmlExport::CreateOutlinePages() if (aTitle.isEmpty()) aTitle = maPageNames[nSdPage]; - aStr.append("<p style=\""); - aStr.append(getParagraphStyle(pOutliner, 0)); - aStr.append("\">"); + lclAppendStyle(aStr, "p", getParagraphStyle(pOutliner, 0)); aStr.append(CreateLink(aLink, aTitle)); aStr.append("</p>"); diff --git a/sd/source/filter/html/htmlex.hxx b/sd/source/filter/html/htmlex.hxx index 56f9e15..53b1292 100644 --- a/sd/source/filter/html/htmlex.hxx +++ b/sd/source/filter/html/htmlex.hxx @@ -83,6 +83,7 @@ class HtmlExport std::vector< SdPage* > maNotesPages; OUString maPath; + OUString maFilterOptions; SdDrawDocument* mpDoc; ::sd::DrawDocShell* mpDocSh; @@ -205,12 +206,18 @@ class HtmlExport void ExportHtml(); void ExportKiosk(); void ExportWebCast(); + void ExportSingleDocument(); bool WriteHtml( const OUString& rFileName, bool bAddExtension, const OUString& rHtmlData ); OUString GetButtonName( int nButton ) const; public: - HtmlExport( const OUString& aPath, const com::sun::star::uno::Sequence< com::sun::star::beans::PropertyValue >& rParams, SdDrawDocument* pExpDoc, ::sd::DrawDocShell* pDocShell ); + HtmlExport(const OUString& aPath, + const css::uno::Sequence<css::beans::PropertyValue>& rParams, + const OUString& rFilterOptions, + SdDrawDocument* pExpDoc, + sd::DrawDocShell* pDocShell); + virtual ~HtmlExport(); static OUString ColorToHTMLString( Color aColor ); diff --git a/sd/source/filter/html/htmlpublishmode.hxx b/sd/source/filter/html/htmlpublishmode.hxx index a7871db..95740c0 100644 --- a/sd/source/filter/html/htmlpublishmode.hxx +++ b/sd/source/filter/html/htmlpublishmode.hxx @@ -20,8 +20,14 @@ #ifndef INCLUDED_SD_SOURCE_FILTER_HTML_HTMLPUBLISHMODE_HXX #define INCLUDED_SD_SOURCE_FILTER_HTML_HTMLPUBLISHMODE_HXX -enum HtmlPublishMode { - PUBLISH_HTML, PUBLISH_FRAMES, PUBLISH_WEBCAST, PUBLISH_KIOSK }; +enum HtmlPublishMode +{ + PUBLISH_HTML, + PUBLISH_FRAMES, + PUBLISH_WEBCAST, + PUBLISH_KIOSK, + PUBLISH_SINGLE_DOCUMENT +}; #endif diff --git a/sd/source/filter/html/sdhtmlfilter.cxx b/sd/source/filter/html/sdhtmlfilter.cxx index 23f27ed..db809d7 100644 --- a/sd/source/filter/html/sdhtmlfilter.cxx +++ b/sd/source/filter/html/sdhtmlfilter.cxx @@ -64,12 +64,17 @@ sal_Bool SdHTMLFilter::Export() SfxItemSet *pSet = mrMedium.GetItemSet(); ::com::sun::star::uno::Sequence< ::com::sun::star::beans::PropertyValue > aParams; + OUString sFilterOptions; const SfxPoolItem* pItem; + if ( pSet->GetItemState( SID_FILTER_DATA, false, &pItem ) == SFX_ITEM_SET ) ((SfxUnoAnyItem*)pItem)->GetValue() >>= aParams; - delete( new HtmlExport( mrMedium.GetName(), aParams, &mrDocument, &mrDocShell ) ); + if (pSet->GetItemState(SID_FILE_FILTEROPTIONS, true, &pItem) == SFX_ITEM_SET) + sFilterOptions = ((SfxStringItem*)pItem)->GetValue(); + + HtmlExport aExport(mrMedium.GetName(), aParams, sFilterOptions, &mrDocument, &mrDocShell); return true; }
_______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits