diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_ContentStream_ListenerState.cpp ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_ContentStream_ListenerState.cpp --- ./OpenDocument-2005-08-08/xp/OD_ContentStream_ListenerState.cpp 2005-08-03 18:28:11.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_ContentStream_ListenerState.cpp 2005-08-09 16:50:11.163612240 -0300 @@ -80,7 +80,7 @@ if (!UT_strcmp("office:automatic-styles", m_elementStack.getStartTag(0)->getName())) { - pStyle = m_pStyles->addStyle(ppAtts, true); + pStyle = m_pStyles->addStyle(ppAtts, true, true); rAction.pushState(pStyle, false); } else { diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_Office_Styles.cpp ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_Office_Styles.cpp --- ./OpenDocument-2005-08-08/xp/OD_Office_Styles.cpp 2005-08-03 17:59:14.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_Office_Styles.cpp 2005-08-09 13:44:39.869826112 -0300 @@ -40,7 +40,50 @@ * Destructor */ OD_Office_Styles::~OD_Office_Styles() { + + UT_GenericVector* pStyleVector; + UT_GenericVector* pPageLayoutVector; + UT_GenericVector* pMasterPageVector; + UT_uint32 i, count; + + UT_VECTOR_PURGEALL(UT_UTF8String*, m_removedParagraphStyles); + + pStyleVector = m_textStyleStyles.enumerate(); + count = pStyleVector->getItemCount(); + for (i=0; igetItemCount(); + for (i=0; igetItemCount(); + for (i=0; igetItemCount(); + for (i=0; igetItemCount(); + for (i=0; i @@ -121,6 +122,21 @@ // UT_GenericStringMap m_sectionStyleStyles; + //// + // Styles defined inside the content stream, only automatic styles. + // ( element) + + // + UT_GenericStringMap m_textStyleStyles_contentStream; + + // + UT_GenericStringMap m_paragraphStyleStyles_contentStream; + + // + UT_GenericStringMap m_sectionStyleStyles_contentStream; + + + // UT_GenericStringMap m_pageLayoutStyles; diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_Style_MasterPage.cpp ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_Style_MasterPage.cpp --- ./OpenDocument-2005-08-08/xp/OD_Style_MasterPage.cpp 2005-08-05 17:23:52.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_Style_MasterPage.cpp 2005-08-08 15:45:14.000000000 -0300 @@ -38,7 +38,9 @@ m_pAbiDocument(pDocument), m_pPageLayoutStyle(NULL), m_postponedHeaderParsing(false), - m_postponedFooterParsing(false) + m_postponedFooterParsing(false), + m_postponedHeaderLeftParsing(false), + m_postponedFooterLeftParsing(false) { } @@ -67,9 +69,16 @@ const XML_Char* ppSecAttr[5]; ppSecAttr[0] = "id"; - ppSecAttr[1] = m_AW_headerSectionID.utf8_str(); ppSecAttr[2] = "type"; - ppSecAttr[3] = "header"; + + if (m_AW_evenHeaderSectionID.empty()) { + ppSecAttr[1] = m_AW_headerSectionID.utf8_str(); + ppSecAttr[3] = "header"; + } else { + ppSecAttr[1] = m_AW_evenHeaderSectionID.utf8_str(); + ppSecAttr[3] = "header-even"; + } + ppSecAttr[4] = 0; m_pAbiDocument->appendStrux(PTX_Section, ppSecAttr); @@ -84,7 +93,11 @@ id = m_pAbiDocument->getUID(UT_UniqueId::HeaderFtr); sprintf(buffer, "%u", id); - m_AW_headerSectionID = buffer; + if (m_AW_headerSectionID.empty()) { + m_AW_headerSectionID = buffer; + } else { + m_AW_evenHeaderSectionID = buffer; + } rAction.postponeElementParsing(this, false); @@ -96,6 +109,79 @@ const XML_Char* ppSecAttr[5]; ppSecAttr[0] = "id"; + ppSecAttr[2] = "type"; + + if (m_AW_evenFooterSectionID.empty()) { + ppSecAttr[1] = m_AW_footerSectionID.utf8_str(); + ppSecAttr[3] = "footer"; + } else { + ppSecAttr[1] = m_AW_evenFooterSectionID.utf8_str(); + ppSecAttr[3] = "footer-even"; + } + + ppSecAttr[4] = 0; + + m_pAbiDocument->appendStrux(PTX_Section, ppSecAttr); + + rAction.pushState("TextContent"); + + } else { + + UT_uint32 id; + char buffer[500]; + + id = m_pAbiDocument->getUID(UT_UniqueId::HeaderFtr); + sprintf(buffer, "%u", id); + + if (m_AW_footerSectionID.empty()) { + m_AW_footerSectionID = buffer; + } else { + m_AW_evenFooterSectionID = buffer; + } + + rAction.postponeElementParsing(this, false); + + m_postponedFooterParsing = true; + } + } else if (!UT_strcmp("style:header-left", pName)) { + + if (m_postponedHeaderLeftParsing) { + + const XML_Char* ppSecAttr[5]; + ppSecAttr[0] = "id"; + ppSecAttr[1] = m_AW_headerSectionID.utf8_str(); + ppSecAttr[2] = "type"; + ppSecAttr[3] = "header"; + ppSecAttr[4] = 0; + + m_pAbiDocument->appendStrux(PTX_Section, ppSecAttr); + + rAction.pushState("TextContent"); + + } else { + + UT_uint32 id; + char buffer[500]; + + id = m_pAbiDocument->getUID(UT_UniqueId::HeaderFtr); + sprintf(buffer, "%u", id); + + if (!m_AW_headerSectionID.empty()) { + m_AW_evenHeaderSectionID = m_AW_headerSectionID; + } + + m_AW_headerSectionID = buffer; + + rAction.postponeElementParsing(this, false); + + m_postponedHeaderLeftParsing = true; + } + } else if (!UT_strcmp("style:footer-left", pName)) { + + if (m_postponedFooterLeftParsing) { + + const XML_Char* ppSecAttr[5]; + ppSecAttr[0] = "id"; ppSecAttr[1] = m_AW_footerSectionID.utf8_str(); ppSecAttr[2] = "type"; ppSecAttr[3] = "footer"; @@ -113,11 +199,15 @@ id = m_pAbiDocument->getUID(UT_UniqueId::HeaderFtr); sprintf(buffer, "%u", id); + if (!m_AW_footerSectionID.empty()) { + m_AW_evenFooterSectionID = m_AW_footerSectionID; + } + m_AW_footerSectionID = buffer; rAction.postponeElementParsing(this, false); - m_postponedFooterParsing = true; + m_postponedFooterLeftParsing = true; } } } diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_Style_MasterPage.h ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_Style_MasterPage.h --- ./OpenDocument-2005-08-08/xp/OD_Style_MasterPage.h 2005-08-05 17:17:33.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_Style_MasterPage.h 2005-08-08 15:20:20.000000000 -0300 @@ -75,6 +75,8 @@ const UT_UTF8String& getAWHeaderSectionID() const {return m_AW_headerSectionID;} const UT_UTF8String& getAWFooterSectionID() const {return m_AW_footerSectionID;} + const UT_UTF8String& getAWEvenHeaderSectionID() const {return m_AW_evenHeaderSectionID;} + const UT_UTF8String& getAWEvenFooterSectionID() const {return m_AW_evenFooterSectionID;} private: @@ -99,6 +101,8 @@ bool m_postponedHeaderParsing; bool m_postponedFooterParsing; + bool m_postponedHeaderLeftParsing; + bool m_postponedFooterLeftParsing; }; #endif //_OD_STYLE_MASTERPAGE_H_ diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_StylesStream_ListenerState.cpp ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_StylesStream_ListenerState.cpp --- ./OpenDocument-2005-08-08/xp/OD_StylesStream_ListenerState.cpp 2005-08-03 18:30:13.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_StylesStream_ListenerState.cpp 2005-08-09 11:17:15.000000000 -0300 @@ -89,12 +89,15 @@ if (!UT_strcmp("office:automatic-styles", m_elementStack.getStartTag(0)->getName())) { - pStyle = m_pStyles->addStyle(ppAtts, true); + pStyle = m_pStyles->addStyle(ppAtts, true, false); } else { - pStyle = m_pStyles->addStyle(ppAtts, false); + pStyle = m_pStyles->addStyle(ppAtts, false, false); } - rAction.pushState(pStyle, false); + // pStyle can be null for unsupported (ignored) styles. + if (pStyle) { + rAction.pushState(pStyle, false); + } } else if (!strcmp (pName, "style:page-layout")) { diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_TextContent_ListenerState.cpp ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_TextContent_ListenerState.cpp --- ./OpenDocument-2005-08-08/xp/OD_TextContent_ListenerState.cpp 2005-08-05 17:31:07.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_TextContent_ListenerState.cpp 2005-08-09 13:28:48.523452744 -0300 @@ -63,7 +63,7 @@ m_col(0), m_cel(0), m_bInTOC(false), - m_bInHeaderFooter(false) + m_bOnContentStream(false) { UT_ASSERT(m_pAbiDocument); UT_ASSERT(m_pStyles); @@ -91,7 +91,8 @@ if (!UT_strcmp(pName, "text:section" )) { const XML_Char* pStyleName = UT_getAttribute ("text:style-name", ppAtts); - const OD_Style_Style* pStyle = m_pStyles->getSectionStyle(pStyleName); + const OD_Style_Style* pStyle = m_pStyles->getSectionStyle(pStyleName, + m_bOnContentStream); _insureInSection(pStyle->getAbiPropsAttrString().utf8_str()); @@ -103,7 +104,7 @@ const OD_Style_Style* pStyle; if (pStyleName) { - pStyle = m_pStyles->getParagraphStyle(pStyleName); + pStyle = m_pStyles->getParagraphStyle(pStyleName, m_bOnContentStream); UT_ASSERT(pStyle); } else { // Use the default style @@ -195,7 +196,7 @@ const OD_Style_Style* pStyle; if (pStyleName) { - pStyle = m_pStyles->getTextStyle(pStyleName); + pStyle = m_pStyles->getTextStyle(pStyleName, m_bOnContentStream); UT_ASSERT(pStyle); } else { // I haven't seen default styles for "text" family. @@ -323,11 +324,16 @@ m_bAcceptingText = false; } else if (!UT_strcmp(pName, "style:header") || - !UT_strcmp(pName, "style:footer")) { + !UT_strcmp(pName, "style:footer") || + !UT_strcmp(pName, "style:header-left") || + !UT_strcmp(pName, "style:footer-left")) { // We are inside a header/footer so, there is already a section defined // on the AbiWord document. m_bInSection = true; - m_bInHeaderFooter = true; + m_bOnContentStream = false; + + } else if (!UT_strcmp(pName, "office:text")) { + m_bOnContentStream = true; } m_elementStack.startElement(pName, ppAtts); @@ -401,18 +407,23 @@ } else if (!UT_strcmp(pName, "office:text")) { + UT_ASSERT(m_bOnContentStream); + // We were inside a element. // We can now bring up the postponed parsing (headers and footers) rAction.bringUpPostponedElements(false); } else if (!UT_strcmp(pName, "style:header") || - !UT_strcmp(pName, "style:footer")) { - + !UT_strcmp(pName, "style:footer") || + !UT_strcmp(pName, "style:header-left") || + !UT_strcmp(pName, "style:footer-left")) { + // We were inside a element. - rAction.popState(); - UT_ASSERT(m_bInHeaderFooter); + UT_ASSERT(!m_bOnContentStream); + + rAction.popState(); } m_elementStack.endElement(pName); @@ -753,16 +764,26 @@ allProps += pMasterPageStyle->getSectionProps(); - const XML_Char* atts[7]; + const XML_Char* atts[20]; UT_uint8 i = 0; atts[i++] = "props"; atts[i++] = allProps.utf8_str(); + if (!pMasterPageStyle->getAWEvenHeaderSectionID().empty()) { + atts[i++] = "header-even"; + atts[i++] = pMasterPageStyle->getAWEvenHeaderSectionID().utf8_str(); + } + if (!pMasterPageStyle->getAWHeaderSectionID().empty()) { atts[i++] = "header"; atts[i++] = pMasterPageStyle->getAWHeaderSectionID().utf8_str(); } + if (!pMasterPageStyle->getAWEvenFooterSectionID().empty()) { + atts[i++] = "footer-even"; + atts[i++] = pMasterPageStyle->getAWEvenFooterSectionID().utf8_str(); + } + if (!pMasterPageStyle->getAWFooterSectionID().empty()) { atts[i++] = "footer"; atts[i++] = pMasterPageStyle->getAWFooterSectionID().utf8_str(); diff -u -N -r ./OpenDocument-2005-08-08/xp/OD_TextContent_ListenerState.h ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_TextContent_ListenerState.h --- ./OpenDocument-2005-08-08/xp/OD_TextContent_ListenerState.h 2005-08-05 05:32:10.000000000 -0300 +++ ./AbiWord-CVS-20050621/abiword-plugins/wp/impexp/OpenDocument/xp/OD_TextContent_ListenerState.h 2005-08-09 13:22:54.999196600 -0300 @@ -111,7 +111,7 @@ int m_col; int m_cel; - bool m_bInHeaderFooter; + bool m_bOnContentStream; void _insertImage (const XML_Char** ppAtts); void _insertBookmark (const XML_Char * name, const XML_Char * type);