diff options
author | Kurt Zenker <kz@openoffice.org> | 2005-03-01 16:05:26 +0000 |
---|---|---|
committer | Kurt Zenker <kz@openoffice.org> | 2005-03-01 16:05:26 +0000 |
commit | b85cf77c3f04b0d102228c6c0e2bd9e8c35916fc (patch) | |
tree | 56c07237811e70d38baa8d22ab6cf4b9ec1930b5 /writerperfect/source | |
parent | a4af4c9a4365ac2bdbe7d17e17d4515c2dee55b8 (diff) |
INTEGRATION: CWS libwpdupgrade (1.1.2); FILE MERGED
2005/02/08 18:55:20 rene 1.1.2.2: fix namespace problems on Solaris/SPARC
again from fridrich_strba@
2005/02/02 20:44:43 rene 1.1.2.1: upgrade writerperfect to new libwpd API and implement --with-system-libwpd.
Remove old libwpd/ stuff, tarball will come when the actual release happened :-)
Diffstat (limited to 'writerperfect/source')
-rw-r--r-- | writerperfect/source/filter/PageSpan.cxx | 115 |
1 files changed, 59 insertions, 56 deletions
diff --git a/writerperfect/source/filter/PageSpan.cxx b/writerperfect/source/filter/PageSpan.cxx index d3d12e60b1c0..e407ffebd50e 100644 --- a/writerperfect/source/filter/PageSpan.cxx +++ b/writerperfect/source/filter/PageSpan.cxx @@ -32,8 +32,10 @@ const float fDefaultPageWidth = 8.5f; // inches (OOo required default: we will handle this later) const float fDefaultPageHeight = 11.0f; // inches -PageSpan::PageSpan(const int iSpan, const float fFormLength, const float fFormWidth, const WPXFormOrientation fFormOrientation, - const float fLeftMargin, const float fRightMargin, const float fTopMargin, const float fBottomMargin): +PageSpan::PageSpan(const WPXPropertyList &xPropList) : +#if 0 +const int iSpan, const float fFormLength, const float fFormWidth, const WPXFormOrientation fFormOrientation, + const float fLeftMargin, const float fRightMargin, const float fTopMargin, const float fBottomMargin): miSpan(iSpan), mfFormLength(fFormLength), mfFormWidth(fFormWidth), @@ -42,6 +44,8 @@ PageSpan::PageSpan(const int iSpan, const float fFormLength, const float fFormWi mfMarginRight(fRightMargin), mfMarginTop(fTopMargin), mfMarginBottom(fBottomMargin), +#endif + mxPropList(xPropList), mpHeaderContent(NULL), mpFooterContent(NULL), mpHeaderLeftContent(NULL), @@ -57,70 +61,70 @@ PageSpan::~PageSpan() delete mpFooterLeftContent; } -void PageSpan::writePageMaster(const int iNum, Reference < XDocumentHandler > &xHandler) const +int PageSpan::getSpan() const { - TagOpenElement pageMasterOpen("style:page-master"); - UTF8String sPageMasterName; - sPageMasterName.sprintf("PM%i", iNum); - pageMasterOpen.addAttribute("style:name", sPageMasterName.getUTF8()); - pageMasterOpen.write(xHandler); - - TagOpenElement pageMasterPropertiesOpen("style:properties"); - UTF8String sMarginTop; - sMarginTop.sprintf("%.4finch", mfMarginTop); - UTF8String sMarginBottom; - sMarginBottom.sprintf("%.4finch", mfMarginBottom); - UTF8String sMarginLeft; - sMarginLeft.sprintf("%.4finch", mfMarginLeft); - UTF8String sMarginRight; - sMarginRight.sprintf("%.4finch", mfMarginRight); - UTF8String sPageWidth; - sPageWidth.sprintf("%.4finch", mfFormWidth); - UTF8String sPageHeight; - sPageHeight.sprintf("%.4finch", mfFormLength); - if (mfFormOrientation == LANDSCAPE) - { - pageMasterPropertiesOpen.addAttribute("style:print-orientation", "landscape"); - } - else - { - pageMasterPropertiesOpen.addAttribute("style:print-orientation", "portrait"); - } - pageMasterPropertiesOpen.addAttribute("fo:page-width", sPageWidth.getUTF8()); - pageMasterPropertiesOpen.addAttribute("fo:page-height", sPageHeight.getUTF8()); - pageMasterPropertiesOpen.addAttribute("fo:margin-top", sMarginTop.getUTF8()); - pageMasterPropertiesOpen.addAttribute("fo:margin-bottom", sMarginBottom.getUTF8()); - pageMasterPropertiesOpen.addAttribute("fo:margin-left", sMarginLeft.getUTF8()); - pageMasterPropertiesOpen.addAttribute("fo:margin-right", sMarginRight.getUTF8()); - pageMasterPropertiesOpen.write(xHandler); - TagCloseElement pageMasterPropertiesClose("style:properties"); - pageMasterPropertiesClose.write(xHandler); - - TagCloseElement pageMasterClose("style:page-master"); - pageMasterClose.write(xHandler); + if (mxPropList["libwpd:num-pages"]) + return mxPropList["libwpd:num-pages"]->getInt(); + + return 0; // should never happen +} + +float PageSpan::getMarginLeft() const +{ + if (mxPropList["fo:margin-left"]) + return mxPropList["fo:margin-left"]->getFloat(); + + return 0.0f; +} + +float PageSpan::getMarginRight() const +{ + if (mxPropList["fo:margin-right"]) + return mxPropList["fo:margin-right"]->getFloat(); + + return 0.0f; +} + +void PageSpan::writePageMaster(const int iNum, DocumentHandler &xHandler) const +{ + WPXPropertyList propList; + + WPXString sPageMasterName; + sPageMasterName.sprintf("PM%i", iNum); + propList.insert("style:name", sPageMasterName); + propList.insert("style:name", sPageMasterName); + xHandler.startElement("style:page-master", propList); + + xHandler.startElement("style:properties", mxPropList); + + xHandler.endElement("style:properties"); + xHandler.endElement("style:page-master"); } -void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, Reference < XDocumentHandler > &xHandler) const +void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum, const bool bLastPageSpan, + DocumentHandler &xHandler) const { + WPXPropertyList propList; // scratch space + int iSpan = 0; - (bLastPageSpan) ? iSpan = 1 : iSpan = miSpan; + (bLastPageSpan) ? iSpan = 1 : iSpan = getSpan(); for (int i=iStartingNum; i<(iStartingNum+iSpan); i++) { TagOpenElement masterPageOpen("style:master-page"); - UTF8String sMasterPageName; + WPXString sMasterPageName; sMasterPageName.sprintf("Page Style %i", i); - UTF8String sPageMasterName; + WPXString sPageMasterName; sPageMasterName.sprintf("PM%i", iPageMasterNum); - masterPageOpen.addAttribute("style:name", sMasterPageName.getUTF8()); - masterPageOpen.addAttribute("style:page-master-name", sPageMasterName.getUTF8()); + propList.insert("style:name", sMasterPageName); + propList.insert("style:page-master-name", sPageMasterName); if (!bLastPageSpan) { - UTF8String sNextMasterPageName; + WPXString sNextMasterPageName; sNextMasterPageName.sprintf("Page Style %i", (i+1)); - masterPageOpen.addAttribute("style:next-style-name", sNextMasterPageName.getUTF8()); + propList.insert("style:next-style-name", sNextMasterPageName); } - masterPageOpen.write(xHandler); + xHandler.startElement("style:master-page", propList); if (mpHeaderContent) _writeHeaderFooter("style:header", *mpHeaderContent, xHandler); @@ -131,19 +135,18 @@ void PageSpan::writeMasterPages(const int iStartingNum, const int iPageMasterNum if (mpFooterLeftContent) _writeHeaderFooter("style:footer-left", *mpFooterLeftContent, xHandler); - TagCloseElement masterPageClose("style:master-page"); - masterPageClose.write(xHandler); + xHandler.endElement("style:master-page"); } } void PageSpan::_writeHeaderFooter(const char *headerFooterTagName, - const vector<DocumentElement *> & headerFooterContent, - Reference < XDocumentHandler > &xHandler) const + const std::vector<DocumentElement *> & headerFooterContent, + DocumentHandler &xHandler) const { TagOpenElement headerFooterOpen(headerFooterTagName); headerFooterOpen.write(xHandler); - for (vector<DocumentElement *>::const_iterator iter = headerFooterContent.begin(); + for (std::vector<DocumentElement *>::const_iterator iter = headerFooterContent.begin(); iter != headerFooterContent.end(); iter++) { (*iter)->write(xHandler); |