diff options
Diffstat (limited to 'writerfilter/source/dmapper')
22 files changed, 3175 insertions, 807 deletions
diff --git a/writerfilter/source/dmapper/DomainMapper.cxx b/writerfilter/source/dmapper/DomainMapper.cxx index 64af3a953eef..65dfb4c5fcec 100644 --- a/writerfilter/source/dmapper/DomainMapper.cxx +++ b/writerfilter/source/dmapper/DomainMapper.cxx @@ -27,6 +27,7 @@ #include "PageBordersHandler.hxx" #include <dmapper/DomainMapper.hxx> +#include <resourcemodel/ResourceModelHelper.hxx> #include <DomainMapper_Impl.hxx> #include <ConversionHelper.hxx> #include <NumberingManager.hxx> @@ -69,6 +70,7 @@ #include <com/sun/star/text/TextGridMode.hpp> #include <com/sun/star/text/XDocumentIndexesSupplier.hpp> #include <com/sun/star/text/WritingMode.hpp> +#include <com/sun/star/text/WritingMode2.hpp> #include <com/sun/star/text/XFootnote.hpp> #include <com/sun/star/style/NumberingType.hpp> #include <comphelper/types.hxx> @@ -98,6 +100,10 @@ using namespace ::com::sun::star; using namespace ::rtl; namespace writerfilter { + +using resourcemodel::resolveSprmProps; +using resourcemodel::resolveAttributeProperties; + namespace dmapper{ #ifdef DEBUG_DOMAINMAPPER @@ -198,6 +204,9 @@ void DomainMapper::attribute(Id nName, Value & val) static ::rtl::OUString sLocalBookmarkName; sal_Int32 nIntValue = val.getInt(); rtl::OUString sStringValue = val.getString(); + + SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext(); + // printf ( "DomainMapper::attribute(0x%.4x, 0x%.4x) [%s]\n", (unsigned int)nName, (unsigned int)nIntValue, ::rtl::OUStringToOString(sStringValue, RTL_TEXTENCODING_DONTKNOW).getStr()); if( nName >= NS_rtf::LN_WIDENT && nName <= NS_rtf::LN_LCBSTTBFUSSR ) m_pImpl->GetFIB().SetData( nName, nIntValue ); @@ -1459,7 +1468,7 @@ void DomainMapper::attribute(Id nName, Value & val) case NS_rtf::LN_sed: /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ //section properties - resolveAttributeProperties(val); + resolveAttributeProperties(*this, val); break; case NS_rtf::LN_tbdAdd: /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ @@ -2133,6 +2142,36 @@ void DomainMapper::attribute(Id nName, Value & val) case NS_ooxml::LN_endtrackchange: m_pImpl->RemoveCurrentRedline( ); break; + case NS_ooxml::LN_CT_DocGrid_linePitch: + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ + { + //see SwWW8ImplReader::SetDocumentGrid + OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); + if(pSectionContext) + { + pSectionContext->SetGridLinePitch( ConversionHelper::convertTwipToMM100( nIntValue ) ); + } + } + break; + case NS_ooxml::LN_CT_DocGrid_charSpace: + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ + { + OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); + if(pSectionContext) + { + pSectionContext->SetDxtCharSpace( nIntValue ); + } + } + break; + case NS_ooxml::LN_CT_DocGrid_type: + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ + { + if (pSectionContext != NULL) + { + pSectionContext->SetGridType(nIntValue); + } + } + break; default: { #if OSL_DEBUG_LEVEL > 0 @@ -2167,7 +2206,7 @@ void DomainMapper::sprm(Sprm & rSprm) void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmType ) { #ifdef DEBUG_DOMAINMAPPER - dmapper_logger->startElement("sprm"); + dmapper_logger->startElement("DomainMapper.sprm"); dmapper_logger->chars(rSprm.toString()); #endif OSL_ENSURE(rContext.get(), "PropertyMap has to be valid!"); @@ -2176,14 +2215,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp sal_uInt32 nSprmId = rSprm.getId(); //needed for page properties - SectionPropertyMap* pSectionContext = 0; - //the section context is not availabe before the first call of startSectionGroup() - if( !m_pImpl->IsAnyTableImport() ) - { - PropertyMapPtr pContext = m_pImpl->GetTopContextOfType(CONTEXT_SECTION); - OSL_ENSURE(pContext.get(), "Section context is not in the stack!"); - pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() ); - } + SectionPropertyMap * pSectionContext = m_pImpl->GetSectionContext(); //TODO: In rtl-paragraphs the meaning of left/right are to be exchanged bool bExchangeLeftRight = false; @@ -2221,8 +2253,9 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break; // sprmPFSideBySide case NS_sprm::LN_PFKeep: // sprmPFKeep - /* WRITERFILTERSTATUS: done: 0, planned: 3, spent: 0 */ + /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */ /* WRITERFILTERSTATUS: comment: */ + rContext->Insert(PROP_PARA_SPLIT, true, uno::makeAny(nIntValue ? false : true)); break; case NS_sprm::LN_PFKeepFollow: // sprmPFKeepFollow /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 1 */ @@ -2297,7 +2330,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp } //create a new tab stop property - this is done with the contained properties - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); //add this property rContext->Insert(PROP_PARA_TAB_STOPS, true, uno::makeAny( m_pImpl->GetCurrentTabStopAndClear())); } @@ -2430,7 +2463,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp case NS_ooxml::LN_CT_PrBase_pBdr: //paragraph border /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); break; /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ case NS_sprm::LN_PBrcTop: // sprmPBrcTop @@ -2584,7 +2617,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break; // sprmPFLocked case NS_sprm::LN_PFWidowControl: case NS_ooxml::LN_CT_PPrBase_widowControl: - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { uno::Any aVal( uno::makeAny( sal_Int8(nIntValue ? 2 : 0 ))); rContext->Insert( PROP_PARA_WIDOWS, true, aVal ); @@ -2641,8 +2674,16 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp } break; // sprmPOutLvl case NS_sprm::LN_PFBiDi: - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ + rContext->Insert(PROP_WRITING_MODE, false, uno::makeAny( text::WritingMode2::RL_TB )); + rContext->Insert(PROP_PARA_ADJUST, false, uno::makeAny( style::ParagraphAdjust_RIGHT )); + break; // sprmPFBiDi + case NS_ooxml::LN_EG_SectPrContents_bidi: + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ + if (pSectionContext != NULL) + pSectionContext->Insert(PROP_WRITING_MODE,false, uno::makeAny( text::WritingMode2::RL_TB)); + break; case NS_sprm::LN_PFNumRMIns: /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ break; // sprmPFNumRMIns @@ -2692,7 +2733,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break; // sprmCChs case NS_sprm::LN_CSymbol: // sprmCSymbol /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ - resolveSprmProps(rSprm); //resolves LN_FONT and LN_CHAR + resolveSprmProps(*this, rSprm); //resolves LN_FONT and LN_CHAR break; case NS_sprm::LN_CFOle2: /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ @@ -2701,7 +2742,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ break; // sprmCIdCharType case NS_sprm::LN_CHighlight: - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { sal_Int32 nColor = 0; if(true ==( mbIsHighlightSet = getColorFromIndex(nIntValue, nColor))) @@ -2729,7 +2770,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ break; // sprmCPlain case NS_sprm::LN_CKcd: - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ rContext->Insert(PROP_CHAR_EMPHASIS, true, uno::makeAny ( getEmphasisValue (nIntValue))); break; // sprmCKcd case NS_sprm::LN_CFEmboss:// sprmCFEmboss @@ -2843,6 +2884,13 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp /* WRITERFILTERSTATUS: */ { uno::Any aBold( uno::makeAny( nIntValue ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL ) ); + +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("charWeight"); + dmapper_logger->attribute("weight", nIntValue ? awt::FontWeight::BOLD : awt::FontWeight::NORMAL); + dmapper_logger->endElement("charWeight"); +#endif + rContext->Insert(ePropertyId, true, aBold ); if( nSprmId != NS_sprm::LN_CFBoldBi ) // sprmCFBoldBi rContext->Insert(PROP_CHAR_WEIGHT_ASIAN, true, aBold ); @@ -3079,7 +3127,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ break; // sprmCPropRMark case NS_sprm::LN_CSfxText: - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ // The file-format has many character animations. We have only // one, so we use it always. Suboptimal solution though. if (nIntValue) @@ -3109,7 +3157,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ break; // sprmCBrc case NS_sprm::LN_CShd: - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */ break; // sprmCShd case NS_sprm::LN_CIdslRMarkDel: /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ @@ -3515,7 +3563,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break; case NS_sprm::LN_SDxtCharSpace: { - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); if(pSectionContext) { @@ -3525,7 +3573,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break; // sprmSDxtCharSpace case NS_sprm::LN_SDyaLinePitch: // sprmSDyaLinePitch { - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ //see SwWW8ImplReader::SetDocumentGrid OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); if(pSectionContext) @@ -3570,8 +3618,9 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp } break; // sprmSClm case NS_sprm::LN_STextFlow: - { + case NS_ooxml::LN_EG_SectPrContents_textDirection: /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ + { /* 0 HoriLR 1 Vert TR 2 Vert TR 3 Vert TT 4 HoriLT only 0 and 1 can be imported correctly */ @@ -3589,7 +3638,16 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break; default:; } - rContext->Insert(PROP_WRITING_MODE, false, uno::makeAny( nDirection ) ); + + PropertyMap * pTargetContext = rContext.get(); + + if (pSectionContext != NULL && + nSprmId == NS_ooxml::LN_EG_SectPrContents_textDirection) + { + pTargetContext = pSectionContext; + } + + pTargetContext->Insert(PROP_WRITING_MODE, false, uno::makeAny( nDirection ) ); } break; // sprmSTextFlow case NS_sprm::LN_TJc: // sprmTJc @@ -3718,11 +3776,11 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp break;//undocumented section properties case NS_sprm::LN_CEastAsianLayout: /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); break; case NS_ooxml::LN_CT_Tabs_tab: /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); m_pImpl->IncorporateTabStop(m_pImpl->m_aCurrentTabStop); m_pImpl->m_aCurrentTabStop = DeletableTabStop(); break; @@ -3739,58 +3797,58 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp m_pImpl->InitTabStopFromStyle( aStyleTabStops ); } } - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); rContext->Insert(PROP_PARA_TAB_STOPS, true, uno::makeAny( m_pImpl->GetCurrentTabStopAndClear())); } break; case NS_ooxml::LN_CT_PPr_sectPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_RPrBase_color: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_RPrBase_rFonts: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_RPrBase_bdr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_RPrBase_eastAsianLayout: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_RPrBase_u: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_RPrBase_lang: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_PPrBase_spacing: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_PPrBase_ind: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_RPrDefault_rPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_PPrDefault_pPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_DocDefaults_pPrDefault: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_DocDefaults_rPrDefault: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_Style_pPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_Style_rPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_PPr_rPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_PPrBase_numPr: - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ - resolveSprmProps(rSprm); + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ + resolveSprmProps(*this, rSprm); break; case NS_ooxml::LN_EG_SectPrContents_footnotePr: - /* WRITERFILTERSTATUS: done: 1ß0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_EG_SectPrContents_endnotePr: /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ m_pImpl->SetInFootnoteProperties( NS_ooxml::LN_EG_SectPrContents_footnotePr == nSprmId ); - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); break; case NS_ooxml::LN_EG_SectPrContents_lnNumType: /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ { - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); LineNumberSettings aSettings = m_pImpl->GetLineNumberSettings(); aSettings.bIsOn = true; m_pImpl->SetLineNumberSettings( aSettings ); @@ -3827,7 +3885,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp { //TODO: What about style sheet import of frame properties } - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); } break; case NS_ooxml::LN_EG_SectPrContents_pgSz: @@ -3839,7 +3897,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp CT_PageSz.h = aLetter.getHeight(); } CT_PageSz.orient = false; - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); if(pSectionContext) { @@ -3853,7 +3911,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp case NS_ooxml::LN_EG_SectPrContents_pgMar: /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ m_pImpl->InitPageMargins(); - resolveSprmProps(rSprm); + resolveSprmProps(*this, rSprm); OSL_ENSURE(pSectionContext, "SectionContext unavailable!"); if(pSectionContext) { @@ -3908,6 +3966,9 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp } } break; + case NS_ooxml::LN_EG_SectPrContents_docGrid: + resolveSprmProps(*this, rSprm); + break; case NS_ooxml::LN_EG_SectPrContents_pgBorders: { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); @@ -3960,7 +4021,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp case NS_ooxml::LN_CT_TblPrBase_tblCellMar: //cell margins /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ { - resolveSprmProps(rSprm);//contains LN_CT_TblCellMar_top, LN_CT_TblCellMar_left, LN_CT_TblCellMar_bottom, LN_CT_TblCellMar_right + resolveSprmProps(*this, rSprm);//contains LN_CT_TblCellMar_top, LN_CT_TblCellMar_left, LN_CT_TblCellMar_bottom, LN_CT_TblCellMar_right } break; case NS_ooxml::LN_CT_TblCellMar_top: @@ -4003,7 +4064,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp } break; case NS_sprm::LN_CFNoProof: //0x875 no grammar and spell checking, unsupported - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */ break; case NS_ooxml::LN_anchor_anchor: // at_character drawing /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ @@ -4104,7 +4165,7 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp /* WRITERFILTERSTATUS: done: 100, planned: 5, spent: 0 */ { m_pImpl->AddNewRedline( ); - resolveSprmProps( rSprm ); + resolveSprmProps(*this, rSprm ); // now the properties author, date and id should be available sal_Int32 nToken = m_pImpl->GetCurrentRedlineToken(); switch( nToken & 0xffff ) @@ -4160,7 +4221,21 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp //TODO: determines whether top/bottom paragraph spacing is added if equal styles are following - unsupported break; case NS_ooxml::LN_EG_SectPrContents_formProt: //section protection, only form editing is enabled - unsupported - /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ + case NS_ooxml::LN_EG_SectPrContents_vAlign: + case NS_ooxml::LN_EG_RPrBase_fitText: + /* WRITERFILTERSTATUS: done: 0, planned: 0, spent: 0 */ + break; + case NS_ooxml::LN_ffdata: + { + writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); + if (pProperties.get() != NULL) + { + FFDataHandler::Pointer_t pFFDataHandler(new FFDataHandler()); + + pProperties->resolve(*pFFDataHandler); + m_pImpl->SetFieldFFData(pFFDataHandler); + } + } break; default: { @@ -4173,7 +4248,8 @@ void DomainMapper::sprm( Sprm& rSprm, PropertyMapPtr rContext, SprmType eSprmTyp } #ifdef DEBUG_DOMAINMAPPER - dmapper_logger->endElement("sprm"); + dmapper_logger->addTag(rContext->toTag()); + dmapper_logger->endElement("DomainMapper.sprm"); #endif } /*-- 09.06.2006 09:52:13--------------------------------------------------- @@ -4183,13 +4259,13 @@ void DomainMapper::entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref) { #ifdef DEBUG_DOMAINMAPPER - dmapper_logger->startElement("entry"); + dmapper_logger->startElement("DomainMapper.entry"); #endif ref->resolve(*this); #ifdef DEBUG_DOMAINMAPPER - dmapper_logger->endElement("entry"); + dmapper_logger->endElement("DomainMapper.entry"); #endif } /*-- 09.06.2006 09:52:13--------------------------------------------------- @@ -4357,6 +4433,12 @@ void DomainMapper::text(const sal_uInt8 * data_, size_t len) { //TODO: Determine the right text encoding (FIB?) ::rtl::OUString sText( (const sal_Char*) data_, len, RTL_TEXTENCODING_MS_1252 ); +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("text"); + dmapper_logger->chars(sText); + dmapper_logger->endElement("text"); +#endif + try { if(len == 1) @@ -4423,11 +4505,6 @@ void DomainMapper::text(const sal_uInt8 * data_, size_t len) pContext.reset(new PropertyMap()); m_pImpl->appendTextPortion( sText, pContext ); -#ifdef DEBUG_DOMAINMAPPER - dmapper_logger->startElement("text"); - dmapper_logger->chars(sText); - dmapper_logger->endElement("text"); -#endif } } catch( const uno::RuntimeException& ) @@ -4819,21 +4896,6 @@ rtl::OUString DomainMapper::getBracketStringFromEnum(const sal_Int32 nIntValue, } } -void DomainMapper::resolveSprmProps(Sprm & rSprm) -{ - writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); - if( pProperties.get()) - pProperties->resolve(*this); -} - -void DomainMapper::resolveAttributeProperties(Value & val) -{ - writerfilter::Reference<Properties>::Pointer_t pProperties = val.getProperties(); - if( pProperties.get()) - pProperties->resolve(*this); -} - - com::sun::star::style::TabAlign DomainMapper::getTabAlignFromValue(const sal_Int32 nIntValue) { switch (nIntValue) diff --git a/writerfilter/source/dmapper/DomainMapperTableManager.cxx b/writerfilter/source/dmapper/DomainMapperTableManager.cxx index 452391fe6300..8783421faaaf 100644 --- a/writerfilter/source/dmapper/DomainMapperTableManager.cxx +++ b/writerfilter/source/dmapper/DomainMapperTableManager.cxx @@ -99,14 +99,14 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) sal_Int32 nIntValue = ((pValue.get() != NULL) ? pValue->getInt() : 0); switch ( nSprmId ) { - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case 0xf661: //sprmTTRLeft left table indent - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ case 0xf614: // sprmTTPreferredWidth - preferred table width - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TblPrBase_tblW: //90722; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TblPrBase_tblInd: //90725 + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { //contains unit and value writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); @@ -132,9 +132,9 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) } } break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case 0x3404:// sprmTTableHeader case NS_ooxml::LN_CT_TrPrBase_tblHeader: //90704 + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ // if nIntValue == 1 then the row is a repeated header line // to prevent later rows from increasing the repeating m_nHeaderRepeat is set to NULL when repeating stops if( nIntValue > 0 && m_nHeaderRepeat >= 0 ) @@ -147,8 +147,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) else m_nHeaderRepeat = -1; break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case 0xd608: // TDefTable + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); if( pProperties.get()) @@ -178,8 +178,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) } } break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case 0xD605: // sprmTTableBorders + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { writerfilter::Reference<Properties>::Pointer_t pProperties = rSprm.getProps(); if( pProperties.get()) @@ -193,14 +193,14 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) } } break; - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ case 0xd632 : //sprmTNewSpacing - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ + /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ case 0xd634 : //sprmTNewSpacing + /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ //TODO: sprms contain default (TNew) and actual border spacing of cells - not resolvable yet break; - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ case 0xd613: //sprmTGridLineProps + /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ // TODO: needs a handler /*contains: GridLineProps"> @@ -216,8 +216,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) */ break; - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ case 0x740a : //sprmTTlp + /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ //TODO: Table look specifier break; case 0x6816 : //unknown @@ -227,10 +227,11 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) case 0x7479 : //unknown case 0xf617 : //unknown case 0xf618 : //unknown + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ bRet = false; break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TblPrBase_tblStyle: //table style name + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { m_sTableStyleName = pValue->getString(); TablePropertyMapPtr pPropMap( new TablePropertyMap ); @@ -238,14 +239,14 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) insertTableProps(pPropMap); } break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TblGridBase_gridCol: + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { getCurrentGrid()->push_back( ConversionHelper::convertTwipToMM100( nIntValue ) ); } break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TcPrBase_vMerge : //vertical merge + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { // values can be: LN_Value_ST_Merge_restart, LN_Value_ST_Merge_continue, in reality the second one is a 0 TablePropertyMapPtr pMergeProps( new TablePropertyMap ); @@ -253,8 +254,8 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) cellProps( pMergeProps); } break; - /* WRITERFILTERSTATUS: done: 1, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TcPrBase_gridSpan: //number of grid positions spanned by this cell + /* WRITERFILTERSTATUS: done: 100, planned: 2, spent: 0 */ { #if DEBUG_DOMAINMAPPER dmapper_logger->startElement("tablemanager.GridSpan"); @@ -264,13 +265,14 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) m_nGridSpan = nIntValue; } break; - /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ case NS_ooxml::LN_CT_TblPrBase_tblLook: + /* WRITERFILTERSTATUS: done: 0, planned: 2, spent: 0 */ break; //todo: table look specifier - /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ case NS_ooxml::LN_CT_TcPrBase_tcW: + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ break; //fixed column width is not supported case NS_ooxml::LN_CT_TrPrBase_cnfStyle: + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ { TablePropertyMapPtr pProps( new TablePropertyMap ); pProps->Insert( PROP_CNF_STYLE, true, uno::makeAny( pValue->getString( ) ) ); @@ -278,9 +280,11 @@ bool DomainMapperTableManager::sprm(Sprm & rSprm) } break; case NS_ooxml::LN_CT_PPrBase_cnfStyle: + /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ // TODO cnfStyle on a paragraph break; case NS_ooxml::LN_CT_TcPrBase_cnfStyle: + /* WRITERFILTERSTATUS: done: 100, planned: 0.5, spent: 0 */ { TablePropertyMapPtr pProps( new TablePropertyMap ); pProps->Insert( PROP_CNF_STYLE, true, uno::makeAny( pValue->getString( ) ) ); diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.cxx b/writerfilter/source/dmapper/DomainMapper_Impl.cxx index c6d347a37281..4c176b59b4ef 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.cxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.cxx @@ -69,6 +69,7 @@ #include <com/sun/star/util/XNumberFormats.hpp> #include <rtl/ustrbuf.hxx> #include <rtl/string.h> +#include "FieldTypes.hxx" #include <tools/string.hxx> #ifdef DEBUG_DOMAINMAPPER @@ -89,269 +90,6 @@ using namespace ::com::sun::star; using namespace ::rtl; namespace writerfilter { namespace dmapper{ -/*-- 08.09.2006 09:39:50--------------------------------------------------- - - -----------------------------------------------------------------------*/ -//defaultswitch { Upper FirstCap Lower } -//Numberingswitch { Arabic, ALPHABETIC, ...} see lcl_ParseNumberingType -enum FieldId -{ - /* ADDRESSBLOCK \d \* MERGEFORMAT -> Addressblock completely unsupported*/ - FIELD_ADDRESSBLOCK - /* ADVANCE \d downvalue \l leftvalue \r rightvalue \u upvalue \x xvalue \y yvalue -> unsupported*/ - ,FIELD_ADVANCE - /* ASK bookmarkname "hint" \d defaultanswer \o \* MERGEFORMAT -> - the hint is not always quoted, inputfield with default answer, prompt before merge (\o) - */ - ,FIELD_ASK - /* AUTONUM \* Numberingswitch -> - mapped to sequence field "AutoNr" - */ - ,FIELD_AUTONUM - /* AUTONUMLGL \* Numberingswitch -> - mapped to sequence field "AutoNr" - */ - ,FIELD_AUTONUMLGL - /* AUTONUMOUT \* Numberingswitch -> - mapped to sequence field "AutoNr" - */ - ,FIELD_AUTONUMOUT - /* AUTHOR NewAuthor \* defaultswitch \* MERGEFORMAT -> - mapped to sequence field "AutoNr" - */ - ,FIELD_AUTHOR - /* COMMENTS "comment" \* MERGEFORMAT -> - Docinfo-Comments - */ - ,FIELD_COMMENTS - /* CREATEDATE \h \* MERGEFORMAT -> - docinfo-created-date - */ - ,FIELD_CREATEDATE - /* DATE \@ "number format" \s \* MERGEFORMAT -> - ww8filterimprovement: multiple languages now supported - */ - ,FIELD_DATE - /* DOCPROPERTY propertyname \* MERGEFORMAT -> - ww8filterimprovement: some fields imported as functionally equivalent fields if possible, - the others imported as UserField - */ - ,FIELD_DOCPROPERTY - /* DOCVARIABLE Name \* MERGEFORMAT -> - ww8filterimprovement: now imported as user fields - */ - ,FIELD_DOCVARIABLE - /* EDITTIME \# "displayformat" \* Numberingswitch \* MERGEFORMAT -> - DocInfo-Modified-Date - ww8filterimprovement: multiple languages now supported - */ - ,FIELD_EDITTIME - /* FILLIN "text to fill in" \d defaultanswer \o \* MERGEFORMAT -> - Function-InputField - */ - ,FIELD_FILLIN - /* FILENAME \p \* * MERGEFORMAT -> - file name (\p with path) - */ - ,FIELD_FILENAME - /* FILESIZE \* NumberingType \* MERGEFORMAT -> - not imported in old ww8 filter, see lcl_ParseNumberingType - todo find alternative field - */ - ,FIELD_FILESIZE - /* =formula \# "number format" - todo find alternative field - */ - ,FIELD_FORMULA - /* GOTOBUTTON text \* MERGEFORMAT -> - not imported in old ww8 filter - todo find alternative field - */ - ,FIELD_GOTOBUTTON - /* HYPERLINK "link" \* MERGEFORMAT -> - not imported in old ww8 filter - ww8filterimprovement: now imported as hyperlink - */ - ,FIELD_HYPERLINK - /* IF condition "then text" "else text" -> - not imported in old ww8 filter - ww8filterimprovement: now imported - todo: condition, if text, else text still missing - */ - ,FIELD_IF - /* INFO NameOfInfo \* MERGEFORMAT -> old - todo: filter imports wrong? - */ - ,FIELD_INFO - /* INCLUDEPICTURE path \* MERGEFORMAT-> - old filter imports an embedded picture - todo: not yet supported - */ - ,FIELD_INCLUDEPICTURE - /* KEYWORDS keyword \* defaultswitch \* Numberingswitch \* MERGEFORMAT -> - DocInfo Keywords - */ - ,FIELD_KEYWORDS - /* LASTSAVEDBY \* MERGEFORMAT -> - DocInfo-Modified-Author - */ - ,FIELD_LASTSAVEDBY - /* MACROBUTTON MacroName quick help text -> - Macro field - */ - ,FIELD_MACROBUTTON - /* MERGEFIELD ColumName \b prefix \f suffix \* MERGEFORMAT -> - ww8filterimprovement: column-only API now upporterd - */ - ,FIELD_MERGEFIELD - /* MERGEREC \* MERGEFORMAT -> - RecordNumber field, maybe without db name - todo: currently unchecked - */ - ,FIELD_MERGEREC - /* MERGESEQ \* MERGEFORMAT -> - not imported in old ww8 filter - ww8filterimprovement: now imported - todo: currently unchecked - */ - ,FIELD_MERGESEQ - /* NEXT text -> - Next record - todo: currently unchecked - */ - ,FIELD_NEXT - /* NEXTIF condition - todo: condition not imported - */ - ,FIELD_NEXTIF - /* PAGE \* Numberingswitch \* MERGEFORMAT -> - see lcl_ParseNumberingType - */ - ,FIELD_PAGE - /* REF targetbkm \f \* MERGEFORMAT -> - imports a ShowVariable (bookmarkname)? - \h hyerlink to paragraph - \p relative to para above/below - \f refenence number - \d separator number separator - \n paragraph number - \r paragraph number in relative context - \t suppres non delimiters - \w paragraph number in full context - \* Upper/Lower... - */ - ,FIELD_REF // - /* REVNUM \* Numberingswitch \* MERGEFORMAT -> - DocInfo-revision number - */ - ,FIELD_REVNUM - /* SAVEDATE \@ "NumberFormat"\* MERGEFORMAT -> - DocInfo-modified-date - */ - ,FIELD_SAVEDATE - /* SECTION \* NumberFormat \* MERGEFORMAT -> - not imported in old ww8 filter see lcl_ParseNumberingType - todo: find alternative - */ - ,FIELD_SECTION - /* SECTIONPAGES \* NumberFormat \* MERGEFORMAT -> - not imported in old ww8 filter see lcl_ParseNumberingType - todo: find alternative - */ - ,FIELD_SECTIONPAGES - /* SEQ sequencename \h \c \n \r \s \* MERGEFORMAT -> - number range name:sequencename value:sequencename+1 - todo: only partially implemented, switches unsupported - */ - ,FIELD_SEQ - /* SET bookmarkname newtext \* MERGEFORMAT -> - SetVariable bookmarkname = newtext - todo: not implemented yet - */ - ,FIELD_SET - /* SKIPIF condition \* MERGEFORMAT -> - ?? - todo: not implemented yet - */ - ,FIELD_SKIPIF - /* STYLEREF stylename \* MERGEFORMAT -> - not imported in old ww8 filter - todo: add an equivalent field type - */ - ,FIELD_STYLEREF - /* SUBJECT subject \* Defaultswitch \* MERGEFORMAT -> - DocInfo - subject - */ - ,FIELD_SUBJECT - /* SYMBOL symbolnumber \* MERGEFORMAT -> - inserts a special char (symbolnumber) - todo: find alternative - */ - ,FIELD_SYMBOL - /* TEMPLATE \* Defaultswitch \* MERGEFORMAT - TemplateName field - */ - ,FIELD_TEMPLATE - /* TIME \@ "number format" \* MERGEFORMAT - ww8filterimprovement: multiple languages now supported - */ - ,FIELD_TIME - /* TITLE \* Defaultswitch \* MERGEFORMAT -> - DocInfo-title - */ - ,FIELD_TITLE - /* USERINITIALS newinitials \* MERGEFORMAT -> - ExtendedUser field (SHORTCUT) - */ - ,FIELD_USERINITIALS - /* USERADDRESS \* MERGEFORMAT -> - not imported in old ww8 filter - todo: find alternative - */ - ,FIELD_USERADDRESS - /* USERNAME newusername \* MERGEFORMAT -> - not imported in old ww8 filter - todo: import as extended user field(s) - */ - ,FIELD_USERNAME - /* - TOC options: - \a Builds a table of figures but does not include the captions's label and number - \b Uses a bookmark to specify area of document from which to build table of contents - \c Builds a table of figures of the given label - \d Defines the separator between sequence and page numbers - \f Builds a table of contents using TC entries instead of outline levels - \h Hyperlinks the entries and page numbers within the table of contents - \l Defines the TC entries field level used to build a table of contents - \n Builds a table of contents or a range of entries, sucah as 1-9, in a table of contents without page numbers - \o Builds a table of contents by using outline levels instead of TC entries - \p Defines the separator between the table entry and its page number - \s Builds a table of contents by using a sequence type - \t Builds a table of contents by using style names other than the standard outline styles - \u Builds a table of contents by using the applied paragraph outline level - \w Preserve tab characters within table entries - \x Preserve newline characters within table entries - \z Hides page numbers within the table of contens when shown in Web Layout View - */ - ,FIELD_TOC - /* - TOC entry: text - \f TC entry in doc with multiple tables - \l Outline Level - \n Suppress page numbers - example: TOC "EntryText \f \l 2 \n - */ - ,FIELD_TC - /* document statistic - number of characters - */ - ,FIELD_NUMCHARS - /* document statistic - number of words - */ - ,FIELD_NUMWORDS - /* document statistic - number of pages - */ - ,FIELD_NUMPAGES -}; struct FieldConversion { ::rtl::OUString sWordCommand; @@ -2543,6 +2281,10 @@ uno::Reference< beans::XPropertySet > DomainMapper_Impl::FindOrCreateFieldMaster -----------------------------------------------------------------------*/ void DomainMapper_Impl::PushFieldContext() { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("pushFieldContext"); +#endif + uno::Reference< text::XTextAppend > xTextAppend = m_aTextAppendStack.top().xTextAppend; //insert a dummy char to make sure the start range doesn't move together with the to-be-appended text xTextAppend->appendTextPortion(::rtl::OUString( '-' ), uno::Sequence< beans::PropertyValue >() ); @@ -2585,11 +2327,74 @@ void FieldContext::AppendCommand(const ::rtl::OUString& rPart) { m_sCommand += rPart; } + +::std::vector<rtl::OUString> FieldContext::GetCommandParts() const +{ + ::std::vector<rtl::OUString> aResult; + sal_Int32 nIndex = 0; + bool bInString = false; + OUString sPart; + while (nIndex != -1) + { + OUString sToken = GetCommand().getToken(0, ' ', nIndex); + bool bInStringNext = bInString; + + if (sToken.getLength() == 0) + continue; + + if (sToken.getStr()[0] == '"') + { + bInStringNext = true; + sToken = sToken.copy(1); + } + if (sToken.getStr()[sToken.getLength() - 1] == '"') + { + bInStringNext = false; + sToken = sToken.copy(0, sToken.getLength() - 1); + } + + if (bInString) + { + if (bInStringNext) + { + sPart += OUString(' '); + sPart += sToken; + } + else + { + sPart += sToken; + aResult.push_back(sPart); + } + } + else + { + if (bInStringNext) + { + sPart = sToken; + } + else + { + aResult.push_back(sToken); + } + } + + bInString = bInStringNext; + } + + return aResult; +} + /*-- 29.01.2007 11:33:15--------------------------------------------------- //collect the pieces of the command -----------------------------------------------------------------------*/ void DomainMapper_Impl::AppendFieldCommand(::rtl::OUString& rPartOfCommand) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("appendFieldCommand"); + dmapper_logger->chars(rPartOfCommand); + dmapper_logger->endElement("appendFieldCommand"); +#endif + FieldContextPtr pContext = m_aFieldStack.top(); OSL_ENSURE( pContext.get(), "no field context available"); if( pContext.get() ) @@ -2601,89 +2406,499 @@ void DomainMapper_Impl::AppendFieldCommand(::rtl::OUString& rPartOfCommand) -----------------------------------------------------------------------*/ typedef std::multimap < sal_Int32, ::rtl::OUString > TOCStyleMap; + +const FieldConversionMap_t & lcl_GetFieldConversion() +{ +static FieldConversionMap_t aFieldConversionMap; +static bool bFilled = false; +if(!bFilled) +{ + static const FieldConversion aFields[] = + { +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ADDRESSBLOCK")), "", "", FIELD_ADDRESSBLOCK }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ADVANCE")), "", "", FIELD_ADVANCE }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ASK")), "SetExpression", "SetExpression", FIELD_ASK }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTONUM")), "SetExpression", "SetExpression", FIELD_AUTONUM }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTONUMLGL")), "SetExpression", "SetExpression", FIELD_AUTONUMLGL }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTONUMOUT")), "SetExpression", "SetExpression", FIELD_AUTONUMOUT }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTHOR")), "Author", "", FIELD_AUTHOR }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATE")), "DateTime", "", FIELD_DATE }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("COMMENTS")), "DocInfo.Description", "", FIELD_COMMENTS }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATEDATE")), "DocInfo.CreateDateTime", "", FIELD_CREATEDATE }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOCPROPERTY")), "", "", FIELD_DOCPROPERTY }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOCVARIABLE")), "User", "", FIELD_DOCVARIABLE }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EDITTIME")), "DocInfo.EditTime", "", FIELD_EDITTIME }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILLIN")), "Input", "", FIELD_FILLIN }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILENAME")), "FileName", "", FIELD_FILENAME }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILESIZE")), "", "", FIELD_FILESIZE }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMULA")), "", "", FIELD_FORMULA }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMCHECKBOX")), "", "", FIELD_FORMCHECKBOX}, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMDROPDOWN")), "", "", FIELD_FORMDROWDOWN}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMTEXT")), "Input", "", FIELD_FORMTEXT}, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GOTOBUTTON")), "", "", FIELD_GOTOBUTTON }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HYPERLINK")), "", "", FIELD_HYPERLINK }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IF")), "ConditionalText", "", FIELD_IF }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INFO")), "","", FIELD_INFO }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INCLUDEPICTURE")), "", "", FIELD_INCLUDEPICTURE}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KEYWORDS")), "DocInfo.KeyWords", "", FIELD_KEYWORDS }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LASTSAVEDBY")), "DocInfo.ChangeAuthor", "", FIELD_LASTSAVEDBY }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MACROBUTTON")), "Macro", "", FIELD_MACROBUTTON }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MERGEFIELD")), "Database", "Database", FIELD_MERGEFIELD}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MERGEREC")), "DatabaseNumberOfSet", "", FIELD_MERGEREC }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MERGESEQ")), "", "", FIELD_MERGESEQ }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NEXT")), "DatabaseNextSet", "", FIELD_NEXT }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NEXTIF")), "DatabaseNextSet", "", FIELD_NEXTIF }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PAGE")), "PageNumber", "", FIELD_PAGE }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REF")), "GetReference", "", FIELD_REF }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REVNUM")), "DocInfo.Revision", "", FIELD_REVNUM }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SAVEDATE")), "DocInfo.Change", "", FIELD_SAVEDATE }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SECTION")), "", "", FIELD_SECTION }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SECTIONPAGES")), "", "", FIELD_SECTIONPAGES }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SEQ")), "SetExpression", "SetExpression", FIELD_SEQ }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET")), "","", FIELD_SET }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SKIPIF")),"", "", FIELD_SKIPIF }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("STYLEREF")),"", "", FIELD_STYLEREF }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SUBJECT")), "DocInfo.Subject", "", FIELD_SUBJECT }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYMBOL")),"", "", FIELD_SYMBOL }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TEMPLATE")), "TemplateName", "", FIELD_TEMPLATE}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TIME")), "DateTime", "", FIELD_TIME }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TITLE")), "DocInfo.Title", "", FIELD_TITLE }, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("USERINITIALS")), "ExtendedUser", "", FIELD_USERINITIALS}, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("USERADDRESS")), "", "", FIELD_USERADDRESS }, +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("USERNAME")), "ExtendedUser", "", FIELD_USERNAME } + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TOC")), "com.sun.star.text.ContentIndex", "", FIELD_TOC}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TC")), "com.sun.star.text.ContentIndexMark", "", FIELD_TC}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMCHARS")), "CharacterCount", "", FIELD_NUMCHARS}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMWORDS")), "WordCount", "", FIELD_NUMWORDS}, + {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMPAGES")), "PageCount", "", FIELD_NUMPAGES}, + +// {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")), "", "", FIELD_}, + + }; + size_t nConversions = sizeof(aFields)/sizeof(FieldConversion); + for( size_t nConversion = 0; nConversion < nConversions; ++nConversion) + { + aFieldConversionMap.insert( FieldConversionMap_t::value_type( + aFields[nConversion].sWordCommand, + aFields[nConversion] )); + } + + bFilled = true; + } + + return aFieldConversionMap; +} + +void DomainMapper_Impl::handleFieldAsk + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties) +{ + //doesn the command contain a variable name? + ::rtl::OUString sVariable, sHint; + + sVariable = lcl_ExctractAskVariableAndHint( pContext->GetCommand(), + sHint ); + if(sVariable.getLength()) + { + // determine field master name + uno::Reference< beans::XPropertySet > xMaster = + FindOrCreateFieldMaster + ("com.sun.star.text.FieldMaster.SetExpression", sVariable ); + + // attach the master to the field + uno::Reference< text::XDependentTextField > xDependentField + ( xFieldInterface, uno::UNO_QUERY_THROW ); + xDependentField->attachTextFieldMaster( xMaster ); + + // set input flag at the field + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName(PROP_IS_INPUT), uno::makeAny( true )); + // set the prompt + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName(PROP_HINT), + uno::makeAny( sHint )); + } + else + { + //don't insert the field + //todo: maybe import a 'normal' input field here? + xFieldInterface = 0; + } +} + +void DomainMapper_Impl::handleAutoNum + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties) +{ + //create a sequence field master "AutoNr" + uno::Reference< beans::XPropertySet > xMaster = + FindOrCreateFieldMaster + ("com.sun.star.text.FieldMaster.SetExpression", + rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoNr") )); + + xMaster->setPropertyValue( rPropNameSupplier.GetName(PROP_SUB_TYPE), + uno::makeAny(text::SetVariableType::SEQUENCE)); + + //apply the numbering type + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName(PROP_NUMBERING_TYPE), + uno::makeAny( lcl_ParseNumberingType(pContext->GetCommand()) )); + // attach the master to the field + uno::Reference< text::XDependentTextField > xDependentField + ( xFieldInterface, uno::UNO_QUERY_THROW ); + xDependentField->attachTextFieldMaster( xMaster ); +} + +void DomainMapper_Impl::handleAuthor + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & /*xFieldInterface*/, + uno::Reference< beans::XPropertySet > xFieldProperties) +{ + xFieldProperties->setPropertyValue + ( rPropNameSupplier.GetName(PROP_FULL_NAME), uno::makeAny( true )); + ::rtl::OUString sParam = + lcl_ExtractParameter(pContext->GetCommand(), sizeof(" AUTHOR") ); + if(sParam.getLength()) + { + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName( PROP_IS_FIXED ), + uno::makeAny( true )); + //PROP_CURRENT_PRESENTATION is set later anyway + } +} + + void DomainMapper_Impl::handleDocProperty + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties) +{ + //some docproperties should be imported as document statistic fields, some as DocInfo fields + //others should be user fields + ::rtl::OUString sParam = + lcl_ExtractParameter(pContext->GetCommand(), sizeof(" DOCPROPERTY") ); + + if(sParam.getLength()) + { + #define SET_ARABIC 0x01 + #define SET_FULL_NAME 0x02 + struct DocPropertyMap + { + const sal_Char* pDocPropertyName; + const sal_Char* pServiceName; + sal_uInt8 nFlags; + }; + static const DocPropertyMap aDocProperties[] = + { + {"Author", "Author", SET_FULL_NAME}, + {"CreateTime", "DocInfo.CreateDateTime", 0}, + {"Characters", "CharacterCount", SET_ARABIC}, + {"Comments", "DocInfo.Description", 0}, + {"Keywords", "DocInfo.KeyWords", 0}, + {"LastPrinted", "DocInfo.PrintDateTime", 0}, + {"LastSavedBy", "DocInfo.ChangeAuthor", 0}, + {"LastSavedTime", "DocInfo.ChangeDateTime", 0}, + {"Paragraphs", "ParagraphCount", SET_ARABIC}, + {"RevisionNumber", "DocInfo.Revision", 0}, + {"Subject", "DocInfo.Subject", 0}, + {"Template", "TemplateName", 0}, + {"Title", "DocInfo.Title", 0}, + {"TotalEditingTime", "DocInfo.EditTime", 9}, + {"Words", "WordCount", SET_ARABIC} + + //other available DocProperties: + //Bytes, Category, CharactersWithSpaces, Company + //HyperlinkBase, + //Lines, Manager, NameofApplication, ODMADocId, Pages, + //Security, + }; + //search for a field mapping + ::rtl::OUString sFieldServiceName; + sal_uInt16 nMap = 0; + for( ; nMap < sizeof(aDocProperties) / sizeof(DocPropertyMap); + ++nMap ) + { + if(sParam.equalsAscii(aDocProperties[nMap].pDocPropertyName)) + { + sFieldServiceName = + ::rtl::OUString::createFromAscii + (aDocProperties[nMap].pServiceName); + break; + } + } + ::rtl::OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM + ("com.sun.star.text.TextField.")); + bool bIsCustomField = false; + if(!sFieldServiceName.getLength()) + { + //create a custom property field + sServiceName += + ::rtl::OUString::createFromAscii("DocInfo.Custom"); + bIsCustomField = true; + } + else + { + sServiceName += sFieldServiceName; + } + xFieldInterface = m_xTextFactory->createInstance(sServiceName); + xFieldProperties = + uno::Reference< beans::XPropertySet >( xFieldInterface, + uno::UNO_QUERY_THROW); + if( bIsCustomField ) + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName(PROP_NAME), uno::makeAny( sParam )); + else + { + if(0 != (aDocProperties[nMap].nFlags & SET_ARABIC)) + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName(PROP_NUMBERING_TYPE), + uno::makeAny( style::NumberingType::ARABIC )); + else if(0 != (aDocProperties[nMap].nFlags & SET_FULL_NAME)) + xFieldProperties->setPropertyValue( + rPropNameSupplier.GetName(PROP_FULL_NAME), + uno::makeAny( true )); + } + } + +#undef SET_ARABIC +#undef SET_FULL_NAME +} + +void DomainMapper_Impl::handleToc + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & /*xFieldInterface*/, + uno::Reference< beans::XPropertySet > /*xFieldProperties*/, + const ::rtl::OUString & sTOCServiceName) +{ + ::rtl::OUString sValue; + bool bTableOfFigures = false; + bool bHyperlinks = false; + bool bFromOutline = false; + bool bFromEntries = false; + sal_Int16 nMaxLevel = 10; + ::rtl::OUString sTemplate; + ::rtl::OUString sChapterNoSeparator; +// \a Builds a table of figures but does not include the captions's label and number + if( lcl_FindInCommand( pContext->GetCommand(), 'a', sValue )) + { //make it a table of figures + bTableOfFigures = true; + } +// \b Uses a bookmark to specify area of document from which to build table of contents +// if( lcl_FindInCommand( pContext->GetCommand(), 'b', sValue )) +// { //todo: sValue contains the bookmark name - unsupported feature +// } + if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue )) +// \c Builds a table of figures of the given label + { + //todo: sValue contains the label's name + bTableOfFigures = true; + } +// \d Defines the separator between sequence and page numbers + if( lcl_FindInCommand( pContext->GetCommand(), 'd', sValue )) + { + //todo: insert the chapter number into each level and insert the separator additionally + sChapterNoSeparator = sValue; + } +// \f Builds a table of contents using TC entries instead of outline levels + if( lcl_FindInCommand( pContext->GetCommand(), 'f', sValue )) + { + //todo: sValue can contain a TOC entry identifier - use unclear + bFromEntries = true; + } +// \h Hyperlinks the entries and page numbers within the table of contents + if( lcl_FindInCommand( pContext->GetCommand(), 'h', sValue )) + { + //todo: make all entries to hyperlinks + bHyperlinks = true; + } +// \l Defines the TC entries field level used to build a table of contents +// if( lcl_FindInCommand( pContext->GetCommand(), 'l', sValue )) +// { + //todo: entries can only be included completely +// } +// \n Builds a table of contents or a range of entries, sucah as 1-9, in a table of contents without page numbers +// if( lcl_FindInCommand( pContext->GetCommand(), 'n', sValue )) +// { + //todo: what does the description mean? +// } +// \o Builds a table of contents by using outline levels instead of TC entries + if( lcl_FindInCommand( pContext->GetCommand(), 'o', sValue )) + { + bFromOutline = true; + UniString sParam( sValue ); + xub_StrLen nIndex = 0; + sParam.GetToken( 0, '-', nIndex ); + nMaxLevel = sal_Int16( sParam.Copy( nIndex ).ToInt32( ) ); + } +// \p Defines the separator between the table entry and its page number + if( lcl_FindInCommand( pContext->GetCommand(), 'p', sValue )) + { } +// \s Builds a table of contents by using a sequence type + if( lcl_FindInCommand( pContext->GetCommand(), 's', sValue )) + { } +// \t Builds a table of contents by using style names other than the standard outline styles + if( lcl_FindInCommand( pContext->GetCommand(), 't', sValue )) + { + sal_Int32 nPos = 0; + ::rtl::OUString sToken = sValue.getToken( 1, '"', nPos); + sTemplate = sToken.getLength() ? sToken : sValue; + } +// \u Builds a table of contents by using the applied paragraph outline level + if( lcl_FindInCommand( pContext->GetCommand(), 'u', sValue )) + { + bFromOutline = true; + //todo: what doesn 'the applied paragraph outline level' refer to? + } +// \w Preserve tab characters within table entries +// if( lcl_FindInCommand( pContext->GetCommand(), 'w', sValue )) +// { + //todo: not supported +// } +// \x Preserve newline characters within table entries +// if( lcl_FindInCommand( pContext->GetCommand(), 'x', sValue )) +// { + //todo: unsupported +// } +// \z Hides page numbers within the table of contens when shown in Web Layout View +// if( lcl_FindInCommand( pContext->GetCommand(), 'z', sValue )) +// { //todo: unsupported feature } + + //if there's no option then it should be created from outline + if( !bFromOutline && !bFromEntries && !sTemplate.getLength() ) + bFromOutline = true; + + uno::Reference< beans::XPropertySet > xTOC( + m_xTextFactory->createInstance + ( bTableOfFigures ? + ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM + ("com.sun.star.text.IllustrationsIndex")) + : sTOCServiceName), + uno::UNO_QUERY_THROW); + xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(::rtl::OUString())); + if( !bTableOfFigures ) + { + xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_LEVEL ), uno::makeAny( nMaxLevel ) ); + xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_OUTLINE ), uno::makeAny( bFromOutline )); + xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_MARKS ), uno::makeAny( bFromEntries )); + if( sTemplate.getLength() ) + { + //the string contains comma separated the names and related levels + //like: "Heading 1,1,Heading 2,2" + TOCStyleMap aMap; + sal_Int32 nLevel; + sal_Int32 nPosition = 0; + while( nPosition >= 0) + { + ::rtl::OUString sStyleName = sTemplate.getToken( 0, ',', nPosition ); + //empty tokens should be skipped + while( !sStyleName.getLength() && nPosition > 0 ) + sStyleName = sTemplate.getToken( 0, ',', nPosition ); + nLevel = sTemplate.getToken( 0, ',', nPosition ).toInt32(); + if( !nLevel ) + nLevel = 1; + if( sStyleName.getLength() ) + aMap.insert( TOCStyleMap::value_type(nLevel, sStyleName) ); + } + uno::Reference< container::XIndexReplace> xParaStyles; + xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_PARAGRAPH_STYLES)) >>= xParaStyles; + for( nLevel = 1; nLevel < 10; ++nLevel) + { + sal_Int32 nLevelCount = aMap.count( nLevel ); + if( nLevelCount ) + { + TOCStyleMap::iterator aTOCStyleIter = aMap.find( nLevel ); + + uno::Sequence< rtl::OUString> aStyles( nLevelCount ); + for ( sal_Int32 nStyle = 0; nStyle < nLevelCount; ++nStyle, ++aTOCStyleIter ) + { + aStyles[nStyle] = aTOCStyleIter->second; + } + xParaStyles->replaceByIndex(nLevel - 1, uno::makeAny(aStyles)); + } + } + xTOC->setPropertyValue(rPropNameSupplier.GetName(PROP_CREATE_FROM_LEVEL_PARAGRAPH_STYLES), uno::makeAny( true )); + + } + if(bHyperlinks || sChapterNoSeparator.getLength()) + { + uno::Reference< container::XIndexReplace> xLevelFormats; + xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_FORMAT)) >>= xLevelFormats; + sal_Int32 nLevelCount = xLevelFormats->getCount(); + //start with level 1, 0 is the header level + for( sal_Int32 nLevel = 1; nLevel < nLevelCount; ++nLevel) + { + uno::Sequence< beans::PropertyValues > aLevel; + xLevelFormats->getByIndex( nLevel ) >>= aLevel; + //create a copy of the level and add two new entries - hyperlink start and end + bool bChapterNoSeparator = sChapterNoSeparator.getLength() > 0; + sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2; + uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd); + beans::PropertyValues* pNewLevel = aNewLevel.getArray(); + if( bHyperlinks ) + { + beans::PropertyValues aHyperlink(1); + aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE ); + aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START ); + pNewLevel[0] = aHyperlink; + aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END ); + pNewLevel[aNewLevel.getLength() -1] = aHyperlink; + } + if( bChapterNoSeparator ) + { + beans::PropertyValues aChapterNo(2); + aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE ); + aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO ); + aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT ); + //todo: is ChapterFormat::Number correct? + aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER; + pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo; + + beans::PropertyValues aChapterSeparator(2); + aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE ); + aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT ); + aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT ); + aChapterSeparator[1].Value <<= sChapterNoSeparator; + pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator; + } + //copy the 'old' entries except the last (page no) + for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken) + { + pNewLevel[nToken + 1] = aLevel[nToken]; + } + //copy page no entry (last or last but one depending on bHyperlinks + sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3); + pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1]; + + xLevelFormats->replaceByIndex( nLevel, uno::makeAny( aNewLevel ) ); + } + } + } + pContext->SetTOC( xTOC ); +} + + /*-- 29.01.2007 11:33:16--------------------------------------------------- //the field command has to be closed (0x14 appeared) -----------------------------------------------------------------------*/ void DomainMapper_Impl::CloseFieldCommand() { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("closeFieldCommand"); +#endif + FieldContextPtr pContext = m_aFieldStack.top(); OSL_ENSURE( pContext.get(), "no field context available"); if( pContext.get() ) { - static FieldConversionMap_t aFieldConversionMap; - static bool bFilled = false; m_bSetUserFieldContent = false; - if(!bFilled) - { - static const FieldConversion aFields[] = - { - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ADDRESSBLOCK")), "", "", FIELD_ADDRESSBLOCK }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ADVANCE")), "", "", FIELD_ADVANCE }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ASK")), "SetExpression", "SetExpression", FIELD_ASK }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTONUM")), "SetExpression", "SetExpression", FIELD_AUTONUM }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTONUMLGL")), "SetExpression", "SetExpression", FIELD_AUTONUMLGL }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTONUMOUT")), "SetExpression", "SetExpression", FIELD_AUTONUMOUT }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AUTHOR")), "Author", "", FIELD_AUTHOR }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DATE")), "DateTime", "", FIELD_DATE }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("COMMENTS")), "DocInfo.Description", "", FIELD_COMMENTS }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("CREATEDATE")), "DocInfo.CreateDateTime", "", FIELD_CREATEDATE }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOCPROPERTY")), "", "", FIELD_DOCPROPERTY }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DOCVARIABLE")), "User", "", FIELD_DOCVARIABLE }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("EDITTIME")), "DocInfo.EditTime", "", FIELD_EDITTIME }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILLIN")), "Input", "", FIELD_FILLIN }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILENAME")), "FileName", "", FIELD_FILENAME }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FILESIZE")), "", "", FIELD_FILESIZE }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("FORMULA")), "", "", FIELD_FORMULA - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("GOTOBUTTON")), "", "", FIELD_GOTOBUTTON }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HYPERLINK")), "", "", FIELD_HYPERLINK }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("IF")), "ConditionalText", "", FIELD_IF }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INFO")), "","", FIELD_INFO }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("INCLUDEPICTURE")), "", "", FIELD_INCLUDEPICTURE}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("KEYWORDS")), "DocInfo.KeyWords", "", FIELD_KEYWORDS }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("LASTSAVEDBY")), "DocInfo.ChangeAuthor", "", FIELD_LASTSAVEDBY }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MACROBUTTON")), "Macro", "", FIELD_MACROBUTTON }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MERGEFIELD")), "Database", "Database", FIELD_MERGEFIELD}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MERGEREC")), "DatabaseNumberOfSet", "", FIELD_MERGEREC }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("MERGESEQ")), "", "", FIELD_MERGESEQ }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NEXT")), "DatabaseNextSet", "", FIELD_NEXT }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NEXTIF")), "DatabaseNextSet", "", FIELD_NEXTIF }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PAGE")), "PageNumber", "", FIELD_PAGE }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REF")), "GetReference", "", FIELD_REF }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("REVNUM")), "DocInfo.Revision", "", FIELD_REVNUM }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SAVEDATE")), "DocInfo.Change", "", FIELD_SAVEDATE }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SECTION")), "", "", FIELD_SECTION }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SECTIONPAGES")), "", "", FIELD_SECTIONPAGES }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SEQ")), "SetExpression", "SetExpression", FIELD_SEQ }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SET")), "","", FIELD_SET }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SKIPIF")),"", "", FIELD_SKIPIF }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("STYLEREF")),"", "", FIELD_STYLEREF }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SUBJECT")), "DocInfo.Subject", "", FIELD_SUBJECT }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("SYMBOL")),"", "", FIELD_SYMBOL }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TEMPLATE")), "TemplateName", "", FIELD_TEMPLATE}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TIME")), "DateTime", "", FIELD_TIME }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TITLE")), "DocInfo.Title", "", FIELD_TITLE }, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("USERINITIALS")), "ExtendedUser", "", FIELD_USERINITIALS}, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("USERADDRESS")), "", "", FIELD_USERADDRESS }, - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("USERNAME")), "ExtendedUser", "", FIELD_USERNAME } - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TOC")), "com.sun.star.text.ContentIndex", "", FIELD_TOC}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("TC")), "com.sun.star.text.ContentIndexMark", "", FIELD_TC}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMCHARS")), "CharacterCount", "", FIELD_NUMCHARS}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMWORDS")), "WordCount", "", FIELD_NUMWORDS}, - {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("NUMPAGES")), "PageCount", "", FIELD_NUMPAGES}, - - // {::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")), "", "", FIELD_}, - - }; - size_t nConversions = sizeof(aFields)/sizeof(FieldConversion); - for( size_t nConversion = 0; nConversion < nConversions; ++nConversion) - { - aFieldConversionMap.insert( FieldConversionMap_t::value_type( - aFields[nConversion].sWordCommand, - aFields[nConversion] )); - } + FieldConversionMap_t aFieldConversionMap = lcl_GetFieldConversion(); - bFilled = true; - } try { uno::Reference< uno::XInterface > xFieldInterface; @@ -2697,14 +2912,31 @@ void DomainMapper_Impl::CloseFieldCommand() if(aIt != aFieldConversionMap.end()) { uno::Reference< beans::XPropertySet > xFieldProperties; - if( FIELD_HYPERLINK != aIt->second.eFieldId && - FIELD_DOCPROPERTY != aIt->second.eFieldId && - FIELD_TOC != aIt->second.eFieldId && - FIELD_TC != aIt->second.eFieldId) + bool bCreateField = true; + switch (aIt->second.eFieldId) + { + case FIELD_HYPERLINK: + case FIELD_DOCPROPERTY: + case FIELD_TOC: + case FIELD_TC: + case FIELD_FORMCHECKBOX: + bCreateField = false; + break; + default: + break; + } + if( bCreateField) { //add the service prefix OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.")); sServiceName += ::rtl::OUString::createFromAscii(aIt->second.cFieldServiceName ); + +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("fieldService"); + dmapper_logger->chars(sServiceName); + dmapper_logger->endElement("fieldService"); +#endif + xFieldInterface = m_xTextFactory->createInstance(sServiceName); xFieldProperties = uno::Reference< beans::XPropertySet >( xFieldInterface, uno::UNO_QUERY_THROW); } @@ -2714,69 +2946,15 @@ void DomainMapper_Impl::CloseFieldCommand() case FIELD_ADDRESSBLOCK: break; case FIELD_ADVANCE : break; case FIELD_ASK : - { - //doesn the command contain a variable name? - ::rtl::OUString sVariable, sHint; - - sVariable = lcl_ExctractAskVariableAndHint( pContext->GetCommand(), sHint ); - if(sVariable.getLength()) - { - // determine field master name - uno::Reference< beans::XPropertySet > xMaster = FindOrCreateFieldMaster( - "com.sun.star.text.FieldMaster.SetExpression", sVariable ); - - // attach the master to the field - uno::Reference< text::XDependentTextField > xDependentField( xFieldInterface, uno::UNO_QUERY_THROW ); - xDependentField->attachTextFieldMaster( xMaster ); - - // set input flag at the field - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_IS_INPUT), uno::makeAny( true )); - // set the prompt - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_HINT), - uno::makeAny( sHint )); - } - else - { - //don't insert the field - //todo: maybe import a 'normal' input field here? - xFieldInterface = 0; - } - } + handleFieldAsk(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties); break; case FIELD_AUTONUM : case FIELD_AUTONUMLGL : case FIELD_AUTONUMOUT : - { - //create a sequence field master "AutoNr" - uno::Reference< beans::XPropertySet > xMaster = FindOrCreateFieldMaster( - "com.sun.star.text.FieldMaster.SetExpression", - rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("AutoNr") )); - - xMaster->setPropertyValue( rPropNameSupplier.GetName(PROP_SUB_TYPE), - uno::makeAny(text::SetVariableType::SEQUENCE)); - - //apply the numbering type - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_NUMBERING_TYPE), - uno::makeAny( lcl_ParseNumberingType(pContext->GetCommand()) )); - // attach the master to the field - uno::Reference< text::XDependentTextField > xDependentField( xFieldInterface, uno::UNO_QUERY_THROW ); - xDependentField->attachTextFieldMaster( xMaster ); - } + handleAutoNum(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties); break; case FIELD_AUTHOR : - { - xFieldProperties->setPropertyValue( rPropNameSupplier.GetName(PROP_FULL_NAME), uno::makeAny( true )); - ::rtl::OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" AUTHOR") ); - if(sParam.getLength()) - { - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName( PROP_IS_FIXED ), uno::makeAny( true )); - //PROP_CURRENT_PRESENTATION is set later anyway - } - } + handleAuthor(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties); break; case FIELD_DATE: { @@ -2807,86 +2985,7 @@ void DomainMapper_Impl::CloseFieldCommand() } break; case FIELD_DOCPROPERTY : - { - //some docproperties should be imported as document statistic fields, some as DocInfo fields - //others should be user fields - ::rtl::OUString sParam = lcl_ExtractParameter(pContext->GetCommand(), sizeof(" DOCPROPERTY") ); - if(sParam.getLength()) - { - #define SET_ARABIC 0x01 - #define SET_FULL_NAME 0x02 - struct DocPropertyMap - { - const sal_Char* pDocPropertyName; - const sal_Char* pServiceName; - sal_uInt8 nFlags; - }; - static const DocPropertyMap aDocProperties[] = - { - {"Author", "Author", SET_FULL_NAME}, - {"CreateTime", "DocInfo.CreateDateTime", 0}, - {"Characters", "CharacterCount", SET_ARABIC}, - {"Comments", "DocInfo.Description", 0}, - {"Keywords", "DocInfo.KeyWords", 0}, - {"LastPrinted", "DocInfo.PrintDateTime", 0}, - {"LastSavedBy", "DocInfo.ChangeAuthor", 0}, - {"LastSavedTime", "DocInfo.ChangeDateTime", 0}, - {"Paragraphs", "ParagraphCount", SET_ARABIC}, - {"RevisionNumber", "DocInfo.Revision", 0}, - {"Subject", "DocInfo.Subject", 0}, - {"Template", "TemplateName", 0}, - {"Title", "DocInfo.Title", 0}, - {"TotalEditingTime", "DocInfo.EditTime", 9}, - {"Words", "WordCount", SET_ARABIC} - - //other available DocProperties: - //Bytes, Category, CharactersWithSpaces, Company - //HyperlinkBase, - //Lines, Manager, NameofApplication, ODMADocId, Pages, - //Security, - }; - //search for a field mapping - ::rtl::OUString sFieldServiceName; - sal_uInt16 nMap = 0; - for( ; nMap < sizeof(aDocProperties) / sizeof(DocPropertyMap); ++nMap ) - { - if(sParam.equalsAscii(aDocProperties[nMap].pDocPropertyName)) - { - sFieldServiceName = ::rtl::OUString::createFromAscii(aDocProperties[nMap].pServiceName); - break; - } - } - ::rtl::OUString sServiceName(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.TextField.")); - bool bIsCustomField = false; - if(!sFieldServiceName.getLength()) - { - //create a custom property field - sServiceName += ::rtl::OUString::createFromAscii("DocInfo.Custom"); - bIsCustomField = true; - } - else - { - sServiceName += sFieldServiceName; - } - xFieldInterface = m_xTextFactory->createInstance(sServiceName); - xFieldProperties = uno::Reference< beans::XPropertySet >( xFieldInterface, uno::UNO_QUERY_THROW); - if( bIsCustomField ) - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_NAME), uno::makeAny( sParam )); - else - { - if(0 != (aDocProperties[nMap].nFlags & SET_ARABIC)) - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_NUMBERING_TYPE), - uno::makeAny( style::NumberingType::ARABIC )); - else if(0 != (aDocProperties[nMap].nFlags & SET_FULL_NAME)) - xFieldProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_FULL_NAME), uno::makeAny( true )); - } - } - } - #undef SET_ARABIC - #undef SET_FULL_NAME + handleDocProperty(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties); break; case FIELD_DOCVARIABLE : { @@ -2919,13 +3018,79 @@ void DomainMapper_Impl::CloseFieldCommand() break; case FIELD_FILESIZE : break; case FIELD_FORMULA : break; + case FIELD_FORMCHECKBOX : + { + FFDataHandler::Pointer_t + pFFDataHandler(pContext->getFFDataHandler()); + FormControlHelper::Pointer_t + pFormControlHelper(new FormControlHelper + (FIELD_FORMCHECKBOX, + m_xTextDocument, pFFDataHandler)); + pContext->setFormControlHelper(pFormControlHelper); + } + break; + case FIELD_FORMDROPDOWN : break; + case FIELD_FORMTEXT : + { + FFDataHandler::Pointer_t pFFDataHandler + (pContext->getFFDataHandler()); + + xFieldProperties->setPropertyValue + (rPropNameSupplier.GetName(PROP_HINT), + uno::makeAny(pFFDataHandler->getStatusText())); + xFieldProperties->setPropertyValue + (rPropNameSupplier.GetName(PROP_HELP), + uno::makeAny(pFFDataHandler->getHelpText())); + xFieldProperties->setPropertyValue + (rPropNameSupplier.GetName(PROP_CONTENT), + uno::makeAny(pFFDataHandler->getTextDefault())); + } + break; case FIELD_GOTOBUTTON : break; case FIELD_HYPERLINK: { - sal_Int32 nStartQuote = pContext->GetCommand().indexOf( '\"' ); - sal_Int32 nEndQuote = nStartQuote < pContext->GetCommand().getLength() + 1 ? pContext->GetCommand().indexOf( '\"', nStartQuote + 1) : -1; - if( nEndQuote > 0) - pContext->SetHyperlinkURL( pContext->GetCommand().copy(nStartQuote + 1, nEndQuote - nStartQuote - 1) ); + ::std::vector<rtl::OUString> aParts = pContext->GetCommandParts(); + ::std::vector<rtl::OUString>::const_iterator aItEnd = aParts.end(); + ::std::vector<rtl::OUString>::const_iterator aPartIt = aParts.begin(); + + OUString sURL; + + while (aPartIt != aItEnd) + { + if (aPartIt->equalsAscii("\\l")) + { + aPartIt++; + + if (aPartIt == aItEnd) + break; + + sURL = OUString('#'); + sURL += *aPartIt; + } + else if (aPartIt->equalsAscii("\\m") || + aPartIt->equalsAscii("\\n")) + { + } + else if (aPartIt->equalsAscii("\\o") || + aPartIt->equalsAscii("\\t")) + { + aPartIt++; + + if (aPartIt == aItEnd) + break; + } + else + { + sURL = *aPartIt; + } + + aPartIt++; + } + + if (sURL.getLength() > 0) + { + pContext->SetHyperlinkURL(sURL); + } } break; case FIELD_IF : break; @@ -3065,211 +3230,8 @@ void DomainMapper_Impl::CloseFieldCommand() case FIELD_USERNAME : //todo: user name is firstname + lastname break; case FIELD_TOC: - { - ::rtl::OUString sValue; - bool bTableOfFigures = false; - bool bHyperlinks = false; - bool bFromOutline = false; - bool bFromEntries = false; - sal_Int16 nMaxLevel = 10; - ::rtl::OUString sTemplate; - ::rtl::OUString sChapterNoSeparator; - // \a Builds a table of figures but does not include the captions's label and number - if( lcl_FindInCommand( pContext->GetCommand(), 'a', sValue )) - { //make it a table of figures - bTableOfFigures = true; - } - // \b Uses a bookmark to specify area of document from which to build table of contents - // if( lcl_FindInCommand( pContext->GetCommand(), 'b', sValue )) - // { //todo: sValue contains the bookmark name - unsupported feature - // } - if( lcl_FindInCommand( pContext->GetCommand(), 'c', sValue )) - // \c Builds a table of figures of the given label - { - //todo: sValue contains the label's name - bTableOfFigures = true; - } - // \d Defines the separator between sequence and page numbers - if( lcl_FindInCommand( pContext->GetCommand(), 'd', sValue )) - { - //todo: insert the chapter number into each level and insert the separator additionally - sChapterNoSeparator = sValue; - } - // \f Builds a table of contents using TC entries instead of outline levels - if( lcl_FindInCommand( pContext->GetCommand(), 'f', sValue )) - { - //todo: sValue can contain a TOC entry identifier - use unclear - bFromEntries = true; - } - // \h Hyperlinks the entries and page numbers within the table of contents - if( lcl_FindInCommand( pContext->GetCommand(), 'h', sValue )) - { - //todo: make all entries to hyperlinks - bHyperlinks = true; - } - // \l Defines the TC entries field level used to build a table of contents - // if( lcl_FindInCommand( pContext->GetCommand(), 'l', sValue )) - // { - //todo: entries can only be included completely - // } - // \n Builds a table of contents or a range of entries, sucah as 1-9, in a table of contents without page numbers - // if( lcl_FindInCommand( pContext->GetCommand(), 'n', sValue )) - // { - //todo: what does the description mean? - // } - // \o Builds a table of contents by using outline levels instead of TC entries - if( lcl_FindInCommand( pContext->GetCommand(), 'o', sValue )) - { - bFromOutline = true; - UniString sParam( sValue ); - xub_StrLen nIndex = 0; - sParam.GetToken( 0, '-', nIndex ); - nMaxLevel = sal_Int16( sParam.Copy( nIndex ).ToInt32( ) ); - } - // \p Defines the separator between the table entry and its page number - if( lcl_FindInCommand( pContext->GetCommand(), 'p', sValue )) - { } - // \s Builds a table of contents by using a sequence type - if( lcl_FindInCommand( pContext->GetCommand(), 's', sValue )) - { } - // \t Builds a table of contents by using style names other than the standard outline styles - if( lcl_FindInCommand( pContext->GetCommand(), 't', sValue )) - { - sal_Int32 nPos = 0; - ::rtl::OUString sToken = sValue.getToken( 1, '"', nPos); - sTemplate = sToken.getLength() ? sToken : sValue; - } - // \u Builds a table of contents by using the applied paragraph outline level - if( lcl_FindInCommand( pContext->GetCommand(), 'u', sValue )) - { - bFromOutline = true; - //todo: what doesn 'the applied paragraph outline level' refer to? - } - // \w Preserve tab characters within table entries - // if( lcl_FindInCommand( pContext->GetCommand(), 'w', sValue )) - // { - //todo: not supported - // } - // \x Preserve newline characters within table entries - // if( lcl_FindInCommand( pContext->GetCommand(), 'x', sValue )) - // { - //todo: unsupported - // } - // \z Hides page numbers within the table of contens when shown in Web Layout View - // if( lcl_FindInCommand( pContext->GetCommand(), 'z', sValue )) - // { //todo: unsupported feature } - - //if there's no option then it should be created from outline - if( !bFromOutline && !bFromEntries && !sTemplate.getLength() ) - bFromOutline = true; - - uno::Reference< beans::XPropertySet > xTOC( - m_xTextFactory->createInstance( - bTableOfFigures ? - ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.IllustrationsIndex")) : - ::rtl::OUString::createFromAscii(aIt->second.cFieldServiceName)), - uno::UNO_QUERY_THROW); - xTOC->setPropertyValue(rPropNameSupplier.GetName( PROP_TITLE ), uno::makeAny(::rtl::OUString())); - if( !bTableOfFigures ) - { - xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_LEVEL ), uno::makeAny( nMaxLevel ) ); - xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_OUTLINE ), uno::makeAny( bFromOutline )); - xTOC->setPropertyValue( rPropNameSupplier.GetName( PROP_CREATE_FROM_MARKS ), uno::makeAny( bFromEntries )); - if( sTemplate.getLength() ) - { - //the string contains comma separated the names and related levels - //like: "Heading 1,1,Heading 2,2" - TOCStyleMap aMap; - sal_Int32 nLevel; - sal_Int32 nPosition = 0; - while( nPosition >= 0) - { - ::rtl::OUString sStyleName = sTemplate.getToken( 0, ',', nPosition ); - //empty tokens should be skipped - while( !sStyleName.getLength() && nPosition > 0 ) - sStyleName = sTemplate.getToken( 0, ',', nPosition ); - nLevel = sTemplate.getToken( 0, ',', nPosition ).toInt32(); - if( !nLevel ) - nLevel = 1; - if( sStyleName.getLength() ) - aMap.insert( TOCStyleMap::value_type(nLevel, sStyleName) ); - } - uno::Reference< container::XIndexReplace> xParaStyles; - xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_PARAGRAPH_STYLES)) >>= xParaStyles; - for( nLevel = 1; nLevel < 10; ++nLevel) - { - sal_Int32 nLevelCount = aMap.count( nLevel ); - if( nLevelCount ) - { - TOCStyleMap::iterator aTOCStyleIter = aMap.find( nLevel ); - - uno::Sequence< rtl::OUString> aStyles( nLevelCount ); - for ( sal_Int32 nStyle = 0; nStyle < nLevelCount; ++nStyle, ++aTOCStyleIter ) - { - aStyles[nStyle] = aTOCStyleIter->second; - } - xParaStyles->replaceByIndex(nLevel - 1, uno::makeAny(aStyles)); - } - } - xTOC->setPropertyValue(rPropNameSupplier.GetName(PROP_CREATE_FROM_LEVEL_PARAGRAPH_STYLES), uno::makeAny( true )); - - } - if(bHyperlinks || sChapterNoSeparator.getLength()) - { - uno::Reference< container::XIndexReplace> xLevelFormats; - xTOC->getPropertyValue(rPropNameSupplier.GetName(PROP_LEVEL_FORMAT)) >>= xLevelFormats; - sal_Int32 nLevelCount = xLevelFormats->getCount(); - //start with level 1, 0 is the header level - for( sal_Int32 nLevel = 1; nLevel < nLevelCount; ++nLevel) - { - uno::Sequence< beans::PropertyValues > aLevel; - xLevelFormats->getByIndex( nLevel ) >>= aLevel; - //create a copy of the level and add two new entries - hyperlink start and end - bool bChapterNoSeparator = sChapterNoSeparator.getLength() > 0; - sal_Int32 nAdd = (bHyperlinks && bChapterNoSeparator) ? 4 : 2; - uno::Sequence< beans::PropertyValues > aNewLevel( aLevel.getLength() + nAdd); - beans::PropertyValues* pNewLevel = aNewLevel.getArray(); - if( bHyperlinks ) - { - beans::PropertyValues aHyperlink(1); - aHyperlink[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE ); - aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_START ); - pNewLevel[0] = aHyperlink; - aHyperlink[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_HYPERLINK_END ); - pNewLevel[aNewLevel.getLength() -1] = aHyperlink; - } - if( bChapterNoSeparator ) - { - beans::PropertyValues aChapterNo(2); - aChapterNo[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE ); - aChapterNo[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_CHAPTER_INFO ); - aChapterNo[1].Name = rPropNameSupplier.GetName( PROP_CHAPTER_FORMAT ); - //todo: is ChapterFormat::Number correct? - aChapterNo[1].Value <<= (sal_Int16)text::ChapterFormat::NUMBER; - pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 4 : 2) ] = aChapterNo; - - beans::PropertyValues aChapterSeparator(2); - aChapterSeparator[0].Name = rPropNameSupplier.GetName( PROP_TOKEN_TYPE ); - aChapterSeparator[0].Value <<= rPropNameSupplier.GetName( PROP_TOKEN_TEXT ); - aChapterSeparator[1].Name = rPropNameSupplier.GetName( PROP_TEXT ); - aChapterSeparator[1].Value <<= sChapterNoSeparator; - pNewLevel[aNewLevel.getLength() - (bHyperlinks ? 3 : 1)] = aChapterSeparator; - } - //copy the 'old' entries except the last (page no) - for( sal_Int32 nToken = 0; nToken < aLevel.getLength() - 1; ++nToken) - { - pNewLevel[nToken + 1] = aLevel[nToken]; - } - //copy page no entry (last or last but one depending on bHyperlinks - sal_Int32 nPageNo = aNewLevel.getLength() - (bHyperlinks ? 2 : 3); - pNewLevel[nPageNo] = aLevel[aLevel.getLength() - 1]; - - xLevelFormats->replaceByIndex( nLevel, uno::makeAny( aNewLevel ) ); - } - } - } - pContext->SetTOC( xTOC ); - } + handleToc(pContext, rPropNameSupplier, xFieldInterface, xFieldProperties, + ::rtl::OUString::createFromAscii(aIt->second.cFieldServiceName)); break; case FIELD_TC : { @@ -3343,6 +3305,11 @@ bool DomainMapper_Impl::IsFieldResultAsString() -----------------------------------------------------------------------*/ void DomainMapper_Impl::SetFieldResult( ::rtl::OUString& rResult ) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("setFieldResult"); + dmapper_logger->chars(rResult); +#endif + FieldContextPtr pContext = m_aFieldStack.top(); OSL_ENSURE( pContext.get(), "no field context available"); if( pContext.get() ) @@ -3388,11 +3355,32 @@ void DomainMapper_Impl::SetFieldResult( ::rtl::OUString& rResult ) } } +void DomainMapper_Impl::SetFieldFFData(FFDataHandler::Pointer_t pFFDataHandler) +{ +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("setFieldFFData"); +#endif + + FieldContextPtr pContext = m_aFieldStack.top(); + if (pContext.get()) + { + pContext->setFFDataHandler(pFFDataHandler); + } + +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("setFieldFFData"); +#endif +} + /*-- 29.01.2007 11:33:17--------------------------------------------------- //the end of field is reached (0x15 appeared) - the command might still be open -----------------------------------------------------------------------*/ void DomainMapper_Impl::PopFieldContext() { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("popFieldContext"); +#endif + FieldContextPtr pContext = m_aFieldStack.top(); OSL_ENSURE( pContext.get(), "no field context available"); if( pContext.get() ) @@ -3426,15 +3414,23 @@ void DomainMapper_Impl::PopFieldContext() uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert( xTextAppend, uno::UNO_QUERY_THROW ); xTextAppendAndConvert->appendTextContent( xToInsert, uno::Sequence< beans::PropertyValue >() ); } - else if(pContext->GetHyperlinkURL().getLength()) + else { - PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); - xCrsr->gotoEnd( true ); + FormControlHelper::Pointer_t pFormControlHelper(pContext->getFormControlHelper()); + if (pFormControlHelper.get() != NULL) + { + uno::Reference<text::XTextRange> xTxtRange(xCrsr, uno::UNO_QUERY); + pFormControlHelper->insertControl(xTxtRange); + } + else if(pContext->GetHyperlinkURL().getLength()) + { + PropertyNameSupplier& rPropNameSupplier = PropertyNameSupplier::GetPropertyNameSupplier(); + xCrsr->gotoEnd( true ); - uno::Reference< beans::XPropertySet > xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW ); - xCrsrProperties->setPropertyValue( - rPropNameSupplier.GetName(PROP_HYPER_LINK_U_R_L), uno:: - makeAny(pContext->GetHyperlinkURL())); + uno::Reference< beans::XPropertySet > xCrsrProperties( xCrsr, uno::UNO_QUERY_THROW ); + xCrsrProperties->setPropertyValue(rPropNameSupplier.GetName(PROP_HYPER_LINK_U_R_L), uno:: + makeAny(pContext->GetHyperlinkURL())); + } } } } @@ -3757,4 +3753,19 @@ void DomainMapper_Impl::ApplySettingsTable() } } } + +SectionPropertyMap * DomainMapper_Impl::GetSectionContext() +{ + SectionPropertyMap* pSectionContext = 0; + //the section context is not availabe before the first call of startSectionGroup() + if( !IsAnyTableImport() ) + { + PropertyMapPtr pContext = GetTopContextOfType(CONTEXT_SECTION); + OSL_ENSURE(pContext.get(), "Section context is not in the stack!"); + pSectionContext = dynamic_cast< SectionPropertyMap* >( pContext.get() ); + } + + return pSectionContext; +} + }} diff --git a/writerfilter/source/dmapper/DomainMapper_Impl.hxx b/writerfilter/source/dmapper/DomainMapper_Impl.hxx index 00881d45968f..145e19412a75 100644 --- a/writerfilter/source/dmapper/DomainMapper_Impl.hxx +++ b/writerfilter/source/dmapper/DomainMapper_Impl.hxx @@ -52,6 +52,8 @@ #include <SettingsTable.hxx> #include <GraphicImport.hxx> #include <OLEHandler.hxx> +#include <FFDataHandler.hxx> +#include <FormControlHelper.hxx> #include <map> #include <string.h> @@ -134,6 +136,8 @@ class FieldContext ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTOC;//TOX ::com::sun::star::uno::Reference< ::com::sun::star::beans::XPropertySet > m_xTC;//TOX entry ::rtl::OUString m_sHyperlinkURL; + FFDataHandler::Pointer_t m_pFFDataHandler; + FormControlHelper::Pointer_t m_pFormControlHelper; public: FieldContext(::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xStart); @@ -159,6 +163,13 @@ public: void SetHyperlinkURL( const ::rtl::OUString& rURL ) { m_sHyperlinkURL = rURL; } const ::rtl::OUString& GetHyperlinkURL() { return m_sHyperlinkURL; } + void setFFDataHandler(FFDataHandler::Pointer_t pFFDataHandler) { m_pFFDataHandler = pFFDataHandler; } + FFDataHandler::Pointer_t getFFDataHandler() const { return m_pFFDataHandler; } + + void setFormControlHelper(FormControlHelper::Pointer_t pFormControlHelper) { m_pFormControlHelper = pFormControlHelper; } + FormControlHelper::Pointer_t getFormControlHelper() const { return m_pFormControlHelper; } + + ::std::vector<rtl::OUString> GetCommandParts() const; }; struct TextAppendContext @@ -487,12 +498,40 @@ public: bool IsOpenField() const; //collect the pieces of the command void AppendFieldCommand(::rtl::OUString& rPartOfCommand); + void handleFieldAsk + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties); + void handleAutoNum + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties); + void handleAuthor + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties); + void handleDocProperty + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties); + void handleToc + (FieldContextPtr pContext, + PropertyNameSupplier& rPropNameSupplier, + uno::Reference< uno::XInterface > & xFieldInterface, + uno::Reference< beans::XPropertySet > xFieldProperties, + const ::rtl::OUString & sTOCServiceName); //the field command has to be closed (0x14 appeared) void CloseFieldCommand(); //the _current_ fields require a string type result while TOCs accept richt results bool IsFieldResultAsString(); //apply the result text to the related field void SetFieldResult( ::rtl::OUString& rResult ); + // set FFData of top field context + void SetFieldFFData( FFDataHandler::Pointer_t pFFDataHandler ); //the end of field is reached (0x15 appeared) - the command might still be open void PopFieldContext(); @@ -557,7 +596,7 @@ public: void ResetParaRedline( ); void ApplySettingsTable(); - + SectionPropertyMap * GetSectionContext(); }; } //namespace dmapper } //namespace writerfilter diff --git a/writerfilter/source/dmapper/FFData.xml b/writerfilter/source/dmapper/FFData.xml new file mode 100644 index 000000000000..525f59391dc4 --- /dev/null +++ b/writerfilter/source/dmapper/FFData.xml @@ -0,0 +1,58 @@ +<model> + <class name="FFDataHandler"> + <parent name="Properties"/> + <typedef name="Pointer_t" type="shared_ptr"/> + <typedef name="DropDownEntries_t"> + <vector type="OUString"/> + </typedef> + <member name="name" type="OUString"/> + <member name="enabled" type="bool"/> + <member name="calcOnExit" type="bool"/> + <member name="entryMacro" type="OUString"/> + <member name="exitMacro" type="OUString"/> + <member name="helpTextType" type="sal_uInt32"/> + <member name="helpText" type="OUString"/> + <member name="statusTextType" type="sal_uInt32"/> + <member name="statusText" type="OUString"/> + <member name="checkboxHeight" type="sal_uInt32"/> + <member name="checkboxAutoHeight" type="bool"/> + <member name="checkboxDefault" type="bool"/> + <member name="checkboxChecked" type="bool"/> + <member name="dropDownResult" type="OUString"/> + <member name="dropDownDefault" type="OUString"/> + <member name="dropDownEntries" type="DropDownEntries_t"/> + <member name="textType" type="sal_uInt32"/> + <member name="textMaxLength" type="sal_uInt32"/> + <member name="textDefault" type="OUString"/> + <member name="textFormat" type="OUString"/> + <sprm> + <element name="name" action="set" id="NS_ooxml::LN_CT_FFData_name"/> + <element name="enabled" action="set" id="NS_ooxml::LN_CT_FFData_enabled"/> + <element name="calcOnExit" action="set" id="NS_ooxml::LN_CT_FFData_calcOnExit"/> + <element name="entryMacro" action="set" id="NS_ooxml::LN_CT_FFData_entryMacro"/> + <element name="exitMacro" action="set" id="NS_ooxml::LN_CT_FFData_exitMacro"/> + <element name="helpText" action="resolve" id="NS_ooxml::LN_CT_FFData_helpText"/> + <element name="statusText" action="resolve" id="NS_ooxml::LN_CT_FFData_statusText"/> + <element name="size" member="checkboxHeight" action="set" id="NS_ooxml::LN_CT_FFCheckBox_size"/> + <element name="sizeAuto" member="checkboxAutoHeight" action="set" id="NS_ooxml::LN_CT_FFCheckBox_sizeAuto"/> + <element name="default" member="checkboxDefault" action="set" id="NS_ooxml::LN_CT_FFCheckBox_default"/> + <element name="checked" member="checkboxChecked" action="set" id="NS_ooxml::LN_CT_FFCheckBox_checked"/> + <element name="checkBox" action="resolve" id="NS_ooxml::LN_CT_FFData_checkBox"/> + <element name="result" member="dropDownResult" action="set" id="NS_ooxml::LN_CT_FFDDList_result"/> + <element name="default" member="dropDownDefault" action="set" id="NS_ooxml::LN_CT_FFDDList_default"/> + <element name="listEntry" member="dropDownEntries" action="pushback" id="NS_ooxml::LN_CT_FFDDList_listEntry"/> + <element name="ddList" action="resolve" id="NS_ooxml::LN_CT_FFData_ddList"/> + <element name="type" member="textType" action="set" id="NS_ooxml::LN_CT_FFTextInput_type"/> + <element name="default" member="textDefault" action="set" id="NS_ooxml::LN_CT_FFTextInput_default"/> + <element name="maxLength" member="textMaxLength" action="set" id="NS_ooxml::LN_CT_FFTextInput_maxLength"/> + <element name="format" member="textFormat" action="set" id="NS_ooxml::LN_CT_FFTextInput_format"/> + <element name="textInput" action="resolve" id="NS_ooxml::LN_CT_FFData_textInput"/> + </sprm> + <attribute> + <attribute name="helpText:type" member="helpTextType" id="NS_ooxml::LN_CT_FFHelpText_type"/> + <attribute name="helpText:val" member="helpText" id="NS_ooxml::LN_CT_FFHelpText_val"/> + <attribute name="statusText:type" member="statusTextType" id="NS_ooxml::LN_CT_FFStatusText_type"/> + <attribute name="statusText:val" member="statusText" id="NS_ooxml::LN_CT_FFStatusText_val"/> + </attribute> + </class> +</model>
\ No newline at end of file diff --git a/writerfilter/source/dmapper/FFDataHandler.cxx b/writerfilter/source/dmapper/FFDataHandler.cxx new file mode 100644 index 000000000000..9f9430401161 --- /dev/null +++ b/writerfilter/source/dmapper/FFDataHandler.cxx @@ -0,0 +1,483 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PropertyMap.hxx,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#include "FFDataHandler.hxx" + +#include <ooxml/resourceids.hxx> +#ifdef DEBUG_DOMAINMAPPER +#include <resourcemodel/QNameToString.hxx> +#include "dmapperLoggers.hxx" +#endif +namespace writerfilter { +namespace dmapper { + +/************************ + * class: FFDataHandler * + ************************/ + +FFDataHandler::FFDataHandler() +: m_bEnabled(false), + m_bCalcOnExit(false), + m_nHelpTextType(0), + m_nStatusTextType(0), + m_nCheckboxHeight(0), + m_bCheckboxAutoHeight(false), + m_bCheckboxDefault(false), + m_bCheckboxChecked(false), + m_nTextType(0), + m_nTextMaxLength(0) +{ +} + + +FFDataHandler::~FFDataHandler() +{ +} + +// member: FFDataHandler::name +void FFDataHandler::setName(const rtl::OUString & r_sName) +{ + m_sName = r_sName; +} + +const rtl::OUString & FFDataHandler::getName() const +{ + return m_sName; +} + +// member: FFDataHandler::enabled +void FFDataHandler::setEnabled(bool r_enabled) +{ + m_bEnabled = r_enabled; +} + +bool FFDataHandler::getEnabled() const +{ + return m_bEnabled; +} + +// member: FFDataHandler::calcOnExit +void FFDataHandler::setCalcOnExit(bool r_calcOnExit) +{ + m_bCalcOnExit = r_calcOnExit; +} + +bool FFDataHandler::getCalcOnExit() const +{ + return m_bCalcOnExit; +} + +// member: FFDataHandler::entryMacro +void FFDataHandler::setEntryMacro(const rtl::OUString & r_sEntryMacro) +{ + m_sEntryMacro = r_sEntryMacro; +} + +const rtl::OUString & FFDataHandler::getEntryMacro() const +{ + return m_sEntryMacro; +} + +// member: FFDataHandler::exitMacro +void FFDataHandler::setExitMacro(const rtl::OUString & r_sExitMacro) +{ + m_sExitMacro = r_sExitMacro; +} + +const rtl::OUString & FFDataHandler::getExitMacro() const +{ + return m_sExitMacro; +} + +// member: FFDataHandler::helpTextType +void FFDataHandler::setHelpTextType(sal_uInt32 r_helpTextType) +{ + m_nHelpTextType = r_helpTextType; +} + +sal_uInt32 FFDataHandler::getHelpTextType() const +{ + return m_nHelpTextType; +} + +// member: FFDataHandler::helpText +void FFDataHandler::setHelpText(const rtl::OUString & r_sHelpText) +{ + m_sHelpText = r_sHelpText; +} + +const rtl::OUString & FFDataHandler::getHelpText() const +{ + return m_sHelpText; +} + +// member: FFDataHandler::statusTextType +void FFDataHandler::setStatusTextType(sal_uInt32 r_statusTextType) +{ + m_nStatusTextType = r_statusTextType; +} + +sal_uInt32 FFDataHandler::getStatusTextType() const +{ + return m_nStatusTextType; +} + +// member: FFDataHandler::statusText +void FFDataHandler::setStatusText(const rtl::OUString & r_sStatusText) +{ + m_sStatusText = r_sStatusText; +} + +const rtl::OUString & FFDataHandler::getStatusText() const +{ + return m_sStatusText; +} + +// member: FFDataHandler::checkboxHeight +void FFDataHandler::setCheckboxHeight(sal_uInt32 r_checkboxHeight) +{ + m_nCheckboxHeight = r_checkboxHeight; +} + +sal_uInt32 FFDataHandler::getCheckboxHeight() const +{ + return m_nCheckboxHeight; +} + +// member: FFDataHandler::checkboxAutoHeight +void FFDataHandler::setCheckboxAutoHeight(bool r_checkboxAutoHeight) +{ + m_bCheckboxAutoHeight = r_checkboxAutoHeight; +} + +bool FFDataHandler::getCheckboxAutoHeight() const +{ + return m_bCheckboxAutoHeight; +} + +// member: FFDataHandler::checkboxDefault +void FFDataHandler::setCheckboxDefault(bool r_checkboxDefault) +{ + m_bCheckboxDefault = r_checkboxDefault; +} + +bool FFDataHandler::getCheckboxDefault() const +{ + return m_bCheckboxDefault; +} + +// member: FFDataHandler::checkboxChecked +void FFDataHandler::setCheckboxChecked(bool r_checkboxChecked) +{ + m_bCheckboxChecked = r_checkboxChecked; +} + +bool FFDataHandler::getCheckboxChecked() const +{ + return m_bCheckboxChecked; +} + +// member: FFDataHandler::dropDownResult +void FFDataHandler::setDropDownResult(const rtl::OUString & r_sDropDownResult) +{ + m_sDropDownResult = r_sDropDownResult; +} + +const rtl::OUString & FFDataHandler::getDropDownResult() const +{ + return m_sDropDownResult; +} + +// member: FFDataHandler::dropDownDefault +void FFDataHandler::setDropDownDefault(const rtl::OUString & r_sDropDownDefault) +{ + m_sDropDownDefault = r_sDropDownDefault; +} + +const rtl::OUString & FFDataHandler::getDropDownDefault() const +{ + return m_sDropDownDefault; +} + +// member: FFDataHandler::dropDownEntries +void FFDataHandler::setDropDownEntries(const FFDataHandler::DropDownEntries_t & r_dropDownEntries) +{ + m_DropDownEntries = r_dropDownEntries; +} + +const FFDataHandler::DropDownEntries_t & FFDataHandler::getDropDownEntries() const +{ + return m_DropDownEntries; +} + +void FFDataHandler::dropDownEntriesPushBack(const rtl::OUString & r_Element) +{ + m_DropDownEntries.push_back(r_Element); +} + +// member: FFDataHandler::textType +void FFDataHandler::setTextType(sal_uInt32 r_textType) +{ + m_nTextType = r_textType; +} + +sal_uInt32 FFDataHandler::getTextType() const +{ + return m_nTextType; +} + +// member: FFDataHandler::textMaxLength +void FFDataHandler::setTextMaxLength(sal_uInt32 r_textMaxLength) +{ + m_nTextMaxLength = r_textMaxLength; +} + +sal_uInt32 FFDataHandler::getTextMaxLength() const +{ + return m_nTextMaxLength; +} + +// member: FFDataHandler::textDefault +void FFDataHandler::setTextDefault(const rtl::OUString & r_sTextDefault) +{ + m_sTextDefault = r_sTextDefault; +} + +const rtl::OUString & FFDataHandler::getTextDefault() const +{ + return m_sTextDefault; +} + +// member: FFDataHandler::textFormat +void FFDataHandler::setTextFormat(const rtl::OUString & r_sTextFormat) +{ + m_sTextFormat = r_sTextFormat; +} + +const rtl::OUString & FFDataHandler::getTextFormat() const +{ + return m_sTextFormat; +} + + +void FFDataHandler::sprm(Sprm & r_Sprm) +{ +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("FFDataHandler.sprm"); + dmapper_logger->chars(r_Sprm.toString()); +#endif + switch(r_Sprm.getId()) + { + case NS_ooxml::LN_CT_FFData_name: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sName = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFData_enabled: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_bEnabled = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFData_calcOnExit: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_bCalcOnExit = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFData_entryMacro: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sEntryMacro = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFData_exitMacro: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sExitMacro = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFData_helpText: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + resolveSprm(r_Sprm); + } + break; + case NS_ooxml::LN_CT_FFData_statusText: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + resolveSprm(r_Sprm); + } + break; + case NS_ooxml::LN_CT_FFCheckBox_size: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_nCheckboxHeight = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFCheckBox_sizeAuto: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_bCheckboxAutoHeight = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFCheckBox_default: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_bCheckboxDefault = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFCheckBox_checked: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_bCheckboxChecked = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFData_checkBox: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + resolveSprm(r_Sprm); + } + break; + case NS_ooxml::LN_CT_FFDDList_result: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sDropDownResult = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFDDList_default: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sDropDownDefault = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFDDList_listEntry: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_DropDownEntries.push_back(r_Sprm.getValue()->getString());; + } + break; + case NS_ooxml::LN_CT_FFData_ddList: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + resolveSprm(r_Sprm); + } + break; + case NS_ooxml::LN_CT_FFTextInput_type: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_nTextType = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFTextInput_default: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sTextDefault = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFTextInput_maxLength: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_nTextMaxLength = r_Sprm.getValue()->getInt(); + } + break; + case NS_ooxml::LN_CT_FFTextInput_format: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sTextFormat = r_Sprm.getValue()->getString(); + } + break; + case NS_ooxml::LN_CT_FFData_textInput: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + resolveSprm(r_Sprm); + } + break; + default: +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("unhandled"); +#endif + break; + } +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("FFDataHandler.sprm"); +#endif +} + +void FFDataHandler::resolveSprm(Sprm & r_Sprm) +{ + writerfilter::Reference<Properties>::Pointer_t pProperties = r_Sprm.getProps(); + if( pProperties.get()) + pProperties->resolve(*this); +} + +void FFDataHandler::attribute(Id name, Value & val) +{ +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("FFDataHandler.attribute"); + dmapper_logger->attribute("name", (*QNameToString::Instance())(name)); + dmapper_logger->attribute("value", val.toString()); + dmapper_logger->endElement("FFDataHandler.attribute"); +#endif + switch (name) + { + case NS_ooxml::LN_CT_FFHelpText_type: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_nHelpTextType = val.getInt(); + } + break; + case NS_ooxml::LN_CT_FFHelpText_val: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sHelpText = val.getString(); + } + break; + case NS_ooxml::LN_CT_FFStatusText_type: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_nStatusTextType = val.getInt(); + } + break; + case NS_ooxml::LN_CT_FFStatusText_val: + /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */ + { + m_sStatusText = val.getString(); + } + break; + default: +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("unhandled"); +#endif + break; + } +} + +}} diff --git a/writerfilter/source/dmapper/FFDataHandler.hxx b/writerfilter/source/dmapper/FFDataHandler.hxx new file mode 100644 index 000000000000..fb7a4ccee950 --- /dev/null +++ b/writerfilter/source/dmapper/FFDataHandler.hxx @@ -0,0 +1,161 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PropertyMap.hxx,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef INCLUDED_FFDataHandler_HXX +#define INCLUDED_FFDataHandler_HXX +#include <resourcemodel/WW8ResourceModel.hxx> +#include <rtl/ustring.hxx> +namespace writerfilter { +namespace dmapper { +class FFDataHandler : public Properties +{ +public: + // typedefs + typedef ::boost::shared_ptr<FFDataHandler> Pointer_t; + typedef ::std::vector<rtl::OUString> DropDownEntries_t; + + // constructor + FFDataHandler(); + // destructor + virtual ~FFDataHandler(); + + // member: name + void setName(const rtl::OUString & r_sName); + const rtl::OUString & getName() const; + + // member: enabled + void setEnabled(bool r_enabled); + bool getEnabled() const; + + // member: calcOnExit + void setCalcOnExit(bool r_calcOnExit); + bool getCalcOnExit() const; + + // member: entryMacro + void setEntryMacro(const rtl::OUString & r_sEntryMacro); + const rtl::OUString & getEntryMacro() const; + + // member: exitMacro + void setExitMacro(const rtl::OUString & r_sExitMacro); + const rtl::OUString & getExitMacro() const; + + // member: helpTextType + void setHelpTextType(sal_uInt32 r_helpTextType); + sal_uInt32 getHelpTextType() const; + + // member: helpText + void setHelpText(const rtl::OUString & r_sHelpText); + const rtl::OUString & getHelpText() const; + + // member: statusTextType + void setStatusTextType(sal_uInt32 r_statusTextType); + sal_uInt32 getStatusTextType() const; + + // member: statusText + void setStatusText(const rtl::OUString & r_sStatusText); + const rtl::OUString & getStatusText() const; + + // member: checkboxHeight + void setCheckboxHeight(sal_uInt32 r_checkboxHeight); + sal_uInt32 getCheckboxHeight() const; + + // member: checkboxAutoHeight + void setCheckboxAutoHeight(bool r_checkboxAutoHeight); + bool getCheckboxAutoHeight() const; + + // member: checkboxDefault + void setCheckboxDefault(bool r_checkboxDefault); + bool getCheckboxDefault() const; + + // member: checkboxChecked + void setCheckboxChecked(bool r_checkboxChecked); + bool getCheckboxChecked() const; + + // member: dropDownResult + void setDropDownResult(const rtl::OUString & r_sDropDownResult); + const rtl::OUString & getDropDownResult() const; + + // member: dropDownDefault + void setDropDownDefault(const rtl::OUString & r_sDropDownDefault); + const rtl::OUString & getDropDownDefault() const; + + // member: dropDownEntries + void setDropDownEntries(const DropDownEntries_t & r_dropDownEntries); + const DropDownEntries_t & getDropDownEntries() const; + void dropDownEntriesPushBack(const rtl::OUString & r_Element); + + // member: textType + void setTextType(sal_uInt32 r_textType); + sal_uInt32 getTextType() const; + + // member: textMaxLength + void setTextMaxLength(sal_uInt32 r_textMaxLength); + sal_uInt32 getTextMaxLength() const; + + // member: textDefault + void setTextDefault(const rtl::OUString & r_sTextDefault); + const rtl::OUString & getTextDefault() const; + + // member: textFormat + void setTextFormat(const rtl::OUString & r_sTextFormat); + const rtl::OUString & getTextFormat() const; + + // sprm + void sprm(Sprm & r_sprm); + void resolveSprm(Sprm & r_sprm); + + // attribute + void attribute(Id name, Value & val); + +private: + rtl::OUString m_sName; + bool m_bEnabled; + bool m_bCalcOnExit; + rtl::OUString m_sEntryMacro; + rtl::OUString m_sExitMacro; + sal_uInt32 m_nHelpTextType; + rtl::OUString m_sHelpText; + sal_uInt32 m_nStatusTextType; + rtl::OUString m_sStatusText; + sal_uInt32 m_nCheckboxHeight; + bool m_bCheckboxAutoHeight; + bool m_bCheckboxDefault; + bool m_bCheckboxChecked; + rtl::OUString m_sDropDownResult; + rtl::OUString m_sDropDownDefault; + DropDownEntries_t m_DropDownEntries; + sal_uInt32 m_nTextType; + sal_uInt32 m_nTextMaxLength; + rtl::OUString m_sTextDefault; + rtl::OUString m_sTextFormat; +}; + + +}} +#endif //INCLUDED_FFDataHandler_HXX diff --git a/writerfilter/source/dmapper/FieldTypes.hxx b/writerfilter/source/dmapper/FieldTypes.hxx new file mode 100644 index 000000000000..d0a98efcb0fb --- /dev/null +++ b/writerfilter/source/dmapper/FieldTypes.hxx @@ -0,0 +1,299 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef INCLUDED_FIELD_TYPES_HXX +#define INCLUDED_FIELD_TYPES_HXX + +namespace writerfilter { +namespace dmapper { + +enum FieldId +{ + /* ADDRESSBLOCK \d \* MERGEFORMAT -> Addressblock completely unsupported*/ + FIELD_ADDRESSBLOCK + /* ADVANCE \d downvalue \l leftvalue \r rightvalue \u upvalue \x xvalue \y yvalue -> unsupported*/ + ,FIELD_ADVANCE + /* ASK bookmarkname "hint" \d defaultanswer \o \* MERGEFORMAT -> + the hint is not always quoted, inputfield with default answer, prompt before merge (\o) + */ + ,FIELD_ASK + /* AUTONUM \* Numberingswitch -> + mapped to sequence field "AutoNr" + */ + ,FIELD_AUTONUM + /* AUTONUMLGL \* Numberingswitch -> + mapped to sequence field "AutoNr" + */ + ,FIELD_AUTONUMLGL + /* AUTONUMOUT \* Numberingswitch -> + mapped to sequence field "AutoNr" + */ + ,FIELD_AUTONUMOUT + /* AUTHOR NewAuthor \* defaultswitch \* MERGEFORMAT -> + mapped to sequence field "AutoNr" + */ + ,FIELD_AUTHOR + /* COMMENTS "comment" \* MERGEFORMAT -> + Docinfo-Comments + */ + ,FIELD_COMMENTS + /* CREATEDATE \h \* MERGEFORMAT -> + docinfo-created-date + */ + ,FIELD_CREATEDATE + /* DATE \@ "number format" \s \* MERGEFORMAT -> + ww8filterimprovement: multiple languages now supported + */ + ,FIELD_DATE + /* DOCPROPERTY propertyname \* MERGEFORMAT -> + ww8filterimprovement: some fields imported as functionally equivalent fields if possible, + the others imported as UserField + */ + ,FIELD_DOCPROPERTY + /* DOCVARIABLE Name \* MERGEFORMAT -> + ww8filterimprovement: now imported as user fields + */ + ,FIELD_DOCVARIABLE + /* EDITTIME \# "displayformat" \* Numberingswitch \* MERGEFORMAT -> + DocInfo-Modified-Date + ww8filterimprovement: multiple languages now supported + */ + ,FIELD_EDITTIME + /* FILLIN "text to fill in" \d defaultanswer \o \* MERGEFORMAT -> + Function-InputField + */ + ,FIELD_FILLIN + /* FILENAME \p \* * MERGEFORMAT -> + file name (\p with path) + */ + ,FIELD_FILENAME + /* FILESIZE \* NumberingType \* MERGEFORMAT -> + not imported in old ww8 filter, see lcl_ParseNumberingType + todo find alternative field + */ + ,FIELD_FILESIZE + /* =formula \# "number format" + todo find alternative field + */ + ,FIELD_FORMULA + /* FORMCHECKBOX */ + ,FIELD_FORMCHECKBOX + /* FORMDROPDOWN */ + ,FIELD_FORMDROPDOWN + /* FORMTEXT */ + ,FIELD_FORMTEXT + /* GOTOBUTTON text \* MERGEFORMAT -> + not imported in old ww8 filter + todo find alternative field + */ + ,FIELD_GOTOBUTTON + /* HYPERLINK "link" \* MERGEFORMAT -> + not imported in old ww8 filter + ww8filterimprovement: now imported as hyperlink + */ + ,FIELD_HYPERLINK + /* IF condition "then text" "else text" -> + not imported in old ww8 filter + ww8filterimprovement: now imported + todo: condition, if text, else text still missing + */ + ,FIELD_IF + /* INFO NameOfInfo \* MERGEFORMAT -> old + todo: filter imports wrong? + */ + ,FIELD_INFO + /* INCLUDEPICTURE path \* MERGEFORMAT-> + old filter imports an embedded picture + todo: not yet supported + */ + ,FIELD_INCLUDEPICTURE + /* KEYWORDS keyword \* defaultswitch \* Numberingswitch \* MERGEFORMAT -> + DocInfo Keywords + */ + ,FIELD_KEYWORDS + /* LASTSAVEDBY \* MERGEFORMAT -> + DocInfo-Modified-Author + */ + ,FIELD_LASTSAVEDBY + /* MACROBUTTON MacroName quick help text -> + Macro field + */ + ,FIELD_MACROBUTTON + /* MERGEFIELD ColumName \b prefix \f suffix \* MERGEFORMAT -> + ww8filterimprovement: column-only API now upporterd + */ + ,FIELD_MERGEFIELD + /* MERGEREC \* MERGEFORMAT -> + RecordNumber field, maybe without db name + todo: currently unchecked + */ + ,FIELD_MERGEREC + /* MERGESEQ \* MERGEFORMAT -> + not imported in old ww8 filter + ww8filterimprovement: now imported + todo: currently unchecked + */ + ,FIELD_MERGESEQ + /* NEXT text -> + Next record + todo: currently unchecked + */ + ,FIELD_NEXT + /* NEXTIF condition + todo: condition not imported + */ + ,FIELD_NEXTIF + /* PAGE \* Numberingswitch \* MERGEFORMAT -> + see lcl_ParseNumberingType + */ + ,FIELD_PAGE + /* REF targetbkm \f \* MERGEFORMAT -> + imports a ShowVariable (bookmarkname)? + \h hyerlink to paragraph + \p relative to para above/below + \f refenence number + \d separator number separator + \n paragraph number + \r paragraph number in relative context + \t suppres non delimiters + \w paragraph number in full context + \* Upper/Lower... + */ + ,FIELD_REF // + /* REVNUM \* Numberingswitch \* MERGEFORMAT -> + DocInfo-revision number + */ + ,FIELD_REVNUM + /* SAVEDATE \@ "NumberFormat"\* MERGEFORMAT -> + DocInfo-modified-date + */ + ,FIELD_SAVEDATE + /* SECTION \* NumberFormat \* MERGEFORMAT -> + not imported in old ww8 filter see lcl_ParseNumberingType + todo: find alternative + */ + ,FIELD_SECTION + /* SECTIONPAGES \* NumberFormat \* MERGEFORMAT -> + not imported in old ww8 filter see lcl_ParseNumberingType + todo: find alternative + */ + ,FIELD_SECTIONPAGES + /* SEQ sequencename \h \c \n \r \s \* MERGEFORMAT -> + number range name:sequencename value:sequencename+1 + todo: only partially implemented, switches unsupported + */ + ,FIELD_SEQ + /* SET bookmarkname newtext \* MERGEFORMAT -> + SetVariable bookmarkname = newtext + todo: not implemented yet + */ + ,FIELD_SET + /* SKIPIF condition \* MERGEFORMAT -> + ?? + todo: not implemented yet + */ + ,FIELD_SKIPIF + /* STYLEREF stylename \* MERGEFORMAT -> + not imported in old ww8 filter + todo: add an equivalent field type + */ + ,FIELD_STYLEREF + /* SUBJECT subject \* Defaultswitch \* MERGEFORMAT -> + DocInfo - subject + */ + ,FIELD_SUBJECT + /* SYMBOL symbolnumber \* MERGEFORMAT -> + inserts a special char (symbolnumber) + todo: find alternative + */ + ,FIELD_SYMBOL + /* TEMPLATE \* Defaultswitch \* MERGEFORMAT + TemplateName field + */ + ,FIELD_TEMPLATE + /* TIME \@ "number format" \* MERGEFORMAT + ww8filterimprovement: multiple languages now supported + */ + ,FIELD_TIME + /* TITLE \* Defaultswitch \* MERGEFORMAT -> + DocInfo-title + */ + ,FIELD_TITLE + /* USERINITIALS newinitials \* MERGEFORMAT -> + ExtendedUser field (SHORTCUT) + */ + ,FIELD_USERINITIALS + /* USERADDRESS \* MERGEFORMAT -> + not imported in old ww8 filter + todo: find alternative + */ + ,FIELD_USERADDRESS + /* USERNAME newusername \* MERGEFORMAT -> + not imported in old ww8 filter + todo: import as extended user field(s) + */ + ,FIELD_USERNAME + /* + TOC options: + \a Builds a table of figures but does not include the captions's label and number + \b Uses a bookmark to specify area of document from which to build table of contents + \c Builds a table of figures of the given label + \d Defines the separator between sequence and page numbers + \f Builds a table of contents using TC entries instead of outline levels + \h Hyperlinks the entries and page numbers within the table of contents + \l Defines the TC entries field level used to build a table of contents + \n Builds a table of contents or a range of entries, sucah as 1-9, in a table of contents without page numbers + \o Builds a table of contents by using outline levels instead of TC entries + \p Defines the separator between the table entry and its page number + \s Builds a table of contents by using a sequence type + \t Builds a table of contents by using style names other than the standard outline styles + \u Builds a table of contents by using the applied paragraph outline level + \w Preserve tab characters within table entries + \x Preserve newline characters within table entries + \z Hides page numbers within the table of contens when shown in Web Layout View + */ + ,FIELD_TOC + /* + TOC entry: text + \f TC entry in doc with multiple tables + \l Outline Level + \n Suppress page numbers + example: TOC "EntryText \f \l 2 \n + */ + ,FIELD_TC + /* document statistic - number of characters + */ + ,FIELD_NUMCHARS + /* document statistic - number of words + */ + ,FIELD_NUMWORDS + /* document statistic - number of pages + */ + ,FIELD_NUMPAGES +}; + +}} +#endif // INCLUDED_FIELD_TYPES_HXX diff --git a/writerfilter/source/dmapper/FormControlHelper.cxx b/writerfilter/source/dmapper/FormControlHelper.cxx new file mode 100644 index 000000000000..eebf921f4963 --- /dev/null +++ b/writerfilter/source/dmapper/FormControlHelper.cxx @@ -0,0 +1,309 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ + +#include <math.h> + +#include <com/sun/star/awt/XControlModel.hpp> +#include <com/sun/star/beans/XPropertySet.hpp> +#include <com/sun/star/container/XIndexContainer.hpp> +#include <com/sun/star/drawing/XControlShape.hpp> +#include <com/sun/star/drawing/XDrawPage.hpp> +#include <com/sun/star/drawing/XDrawPageSupplier.hpp> +#include <com/sun/star/form/XForm.hpp> +#include <com/sun/star/form/XFormComponent.hpp> +#include <com/sun/star/form/XFormsSupplier.hpp> +#include <com/sun/star/lang/XMultiServiceFactory.hpp> +#include <com/sun/star/text/TextContentAnchorType.hpp> +#include <com/sun/star/text/VertOrientation.hpp> +#include <com/sun/star/uno/Any.hxx> +#include <com/sun/star/uno/Type.hxx> + +#include "FormControlHelper.hxx" + +namespace writerfilter { +namespace dmapper { + +using namespace ::com::sun::star; + +struct FormControlHelper::FormControlHelper_Impl +{ + FieldId m_eFieldId; + awt::Size aSize; + uno::Reference<drawing::XDrawPage> rDrawPage; + uno::Reference<form::XForm> rForm; + uno::Reference<form::XFormComponent> rFormComponent; + uno::Reference<lang::XMultiServiceFactory> rServiceFactory; + uno::Reference<text::XTextDocument> rTextDocument; + + uno::Reference<drawing::XDrawPage> getDrawPage(); + uno::Reference<lang::XMultiServiceFactory> getServiceFactory(); + uno::Reference<form::XForm> getForm(); + uno::Reference<container::XIndexContainer> getFormComps(); +}; + +uno::Reference<drawing::XDrawPage> FormControlHelper::FormControlHelper_Impl::getDrawPage() +{ + if (! rDrawPage.is()) + { + uno::Reference<drawing::XDrawPageSupplier> + xDrawPageSupplier(rTextDocument, uno::UNO_QUERY); + if (xDrawPageSupplier.is()) + rDrawPage = xDrawPageSupplier->getDrawPage(); + } + + return rDrawPage; +} + +uno::Reference<lang::XMultiServiceFactory> FormControlHelper::FormControlHelper_Impl::getServiceFactory() +{ + if (! rServiceFactory.is()) + rServiceFactory = uno::Reference<lang::XMultiServiceFactory>(rTextDocument, uno::UNO_QUERY); + + return rServiceFactory; +} + +uno::Reference<form::XForm> FormControlHelper::FormControlHelper_Impl::getForm() +{ + if (! rForm.is()) + { + uno::Reference<form::XFormsSupplier> xFormsSupplier(getDrawPage(), uno::UNO_QUERY); + + if (xFormsSupplier.is()) + { + uno::Reference<container::XNameContainer> xFormsNamedContainer(xFormsSupplier->getForms()); + static ::rtl::OUString sDOCXForm(RTL_CONSTASCII_USTRINGPARAM("DOCX-Standard")); + + ::rtl::OUString sFormName(sDOCXForm); + sal_uInt16 nUnique = 0; + + while (xFormsNamedContainer->hasByName(sFormName)) + { + ++nUnique; + sFormName = sDOCXForm; + sFormName += ::rtl::OUString::valueOf(nUnique); + } + + uno::Reference<uno::XInterface> + xForm(getServiceFactory()->createInstance + (::rtl::OUString + (RTL_CONSTASCII_USTRINGPARAM + ("com.sun.star.form.component.Form")))); + if (xForm.is()) + { + uno::Reference<beans::XPropertySet> + xFormProperties(xForm, uno::UNO_QUERY); + uno::Any aAny(sFormName); + static ::rtl::OUString sName(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name"))); + xFormProperties->setPropertyValue(sName, aAny); + } + + rForm = uno::Reference<form::XForm>(xForm, uno::UNO_QUERY); + + uno::Reference<container::XIndexContainer> xForms(xFormsNamedContainer, uno::UNO_QUERY); + uno::Any aAny(xForm); + xForms->insertByIndex(xForms->getCount(), aAny); + } + } + + return rForm; +} + +uno::Reference<container::XIndexContainer> FormControlHelper::FormControlHelper_Impl::getFormComps() +{ + uno::Reference<container::XIndexContainer> xIndexContainer(getForm(), uno::UNO_QUERY); + + return xIndexContainer; +} + +FormControlHelper::FormControlHelper(FieldId eFieldId, + uno::Reference<text::XTextDocument> rTextDocument, + FFDataHandler::Pointer_t pFFData) + : m_pFFData(pFFData), m_pImpl(new FormControlHelper_Impl) +{ + m_pImpl->m_eFieldId = eFieldId; + m_pImpl->rTextDocument = rTextDocument; +} + +FormControlHelper::~FormControlHelper() +{ +} + +bool FormControlHelper::createCheckbox(uno::Reference<text::XTextRange> xTextRange, + const ::rtl::OUString & rControlName) +{ + uno::Reference<lang::XMultiServiceFactory> + xServiceFactory(m_pImpl->getServiceFactory()); + + if (! xServiceFactory.is()) + return false; + + uno::Reference<uno::XInterface> xInterface = + xServiceFactory->createInstance + (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.form.component.CheckBox"))); + + if (!xInterface.is()) + return false; + + m_pImpl->rFormComponent = uno::Reference<form::XFormComponent>(xInterface, uno::UNO_QUERY); + if (!m_pImpl->rFormComponent.is()) + return false; + + uno::Reference<beans::XPropertySet> xPropSet(xInterface, uno::UNO_QUERY); + + sal_uInt32 nCheckBoxHeight = 16 * m_pFFData->getCheckboxHeight(); + + if (m_pFFData->getCheckboxAutoHeight()) + { + uno::Reference<beans::XPropertySet> xTextRangeProps(xTextRange, uno::UNO_QUERY); + + try + { + static ::rtl::OUString sCharHeight(RTL_CONSTASCII_USTRINGPARAM("CharHeight")); + float fCheckBoxHeight = 0.0; + xTextRangeProps->getPropertyValue(sCharHeight) >>= fCheckBoxHeight; + nCheckBoxHeight = floor(fCheckBoxHeight * 35.3); + } + catch (beans::UnknownPropertyException & rException) + { + } + } + + m_pImpl->aSize.Width = nCheckBoxHeight; + m_pImpl->aSize.Height = m_pImpl->aSize.Width; + + uno::Any aAny; + if (m_pFFData->getStatusText().getLength()) + { + aAny <<= m_pFFData->getStatusText(); + + xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpText")), aAny); + } + + aAny <<= m_pFFData->getCheckboxChecked(); + xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("DefaultState")), aAny); + + if (m_pFFData->getHelpText().getLength()) + { + aAny <<= m_pFFData->getHelpText(); + xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HelpF1Text")), aAny); + } + + aAny <<= rControlName; + xPropSet->setPropertyValue(::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Name")), aAny); + + return true; +} + +bool FormControlHelper::insertControl(uno::Reference<text::XTextRange> xTextRange) +{ + bool bCreated = false; + + uno::Reference<container::XNameContainer> xFormCompsByName(m_pImpl->getForm(), uno::UNO_QUERY); + uno::Reference<container::XIndexContainer> xFormComps(m_pImpl->getFormComps()); + if (! xFormComps.is()) + return false; + + static ::rtl::OUString sControl(RTL_CONSTASCII_USTRINGPARAM("Control")); + + sal_Int32 nControl = 0; + bool bDone = false; + ::rtl::OUString sControlName; + + do + { + ::rtl::OUString sTmp(sControl); + sTmp += ::rtl::OUString::valueOf(nControl); + + nControl++; + if (! xFormCompsByName->hasByName(sTmp)) + { + sControlName = sTmp; + bDone = true; + } + } + while (! bDone); + + switch (m_pImpl->m_eFieldId) + { + case FIELD_FORMCHECKBOX: + bCreated = createCheckbox(xTextRange, sControlName); + break; + default: + break; + } + + if (!bCreated) + return false; + + uno::Any aAny(m_pImpl->rFormComponent); + xFormComps->insertByIndex(xFormComps->getCount(), aAny); + + if (! m_pImpl->getServiceFactory().is()) + return false; + + uno::Reference<uno::XInterface> xInterface = + m_pImpl->getServiceFactory()->createInstance + (::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.drawing.ControlShape"))); + + if (! xInterface.is()) + return false; + + uno::Reference<drawing::XShape> xShape(xInterface, uno::UNO_QUERY); + + if (! xShape.is()) + return false; + + xShape->setSize(m_pImpl->aSize); + + uno::Reference<beans::XPropertySet> xShapeProps(xShape, uno::UNO_QUERY); + + sal_uInt16 nTmp = text::TextContentAnchorType_AS_CHARACTER; + aAny <<= nTmp; + + static const ::rtl::OUString sAnchorType(RTL_CONSTASCII_USTRINGPARAM("AnchorType")); + xShapeProps->setPropertyValue(sAnchorType, aAny); + + static const ::rtl::OUString sVertOrient(RTL_CONSTASCII_USTRINGPARAM("VertOrient")); + nTmp = text::VertOrientation::CENTER; + aAny <<= nTmp; + xShapeProps->setPropertyValue(sVertOrient, aAny); + + aAny <<= xTextRange; + + static const ::rtl::OUString sTextRange(RTL_CONSTASCII_USTRINGPARAM("TextRange")); + xShapeProps->setPropertyValue(sTextRange, aAny); + + uno::Reference<drawing::XControlShape> xControlShape(xShape, uno::UNO_QUERY); + uno::Reference<awt::XControlModel> xControlModel(m_pImpl->rFormComponent, uno::UNO_QUERY); + xControlShape->setControl(xControlModel); + + m_pImpl->getDrawPage()->add(xShape); + + return true; +} + +}} diff --git a/writerfilter/source/dmapper/FormControlHelper.hxx b/writerfilter/source/dmapper/FormControlHelper.hxx new file mode 100644 index 000000000000..21b50912a039 --- /dev/null +++ b/writerfilter/source/dmapper/FormControlHelper.hxx @@ -0,0 +1,64 @@ +/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2000, 2010 Oracle and/or its affiliates. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/ +#ifndef INCLUDED_FORM_CONTROL_HELPER_HXX +#define INCLUDED_FORM_CONTROL_HELPER_HXX + +#include <FFDataHandler.hxx> +#include <com/sun/star/text/XTextDocument.hpp> +#include <com/sun/star/uno/Reference.hxx> +#include "FieldTypes.hxx" + +namespace writerfilter { +namespace dmapper { + +using namespace ::com::sun::star; + +class FormControlHelper +{ +public: + typedef boost::shared_ptr<FormControlHelper> Pointer_t; + FormControlHelper(FieldId eFieldId, + uno::Reference<text::XTextDocument> rTextDocument, + FFDataHandler::Pointer_t pFFData); + ~FormControlHelper(); + + bool insertControl(uno::Reference<text::XTextRange> xTextRange); + +private: + FFDataHandler::Pointer_t m_pFFData; + struct FormControlHelper_Impl; + typedef boost::shared_ptr<FormControlHelper_Impl> ImplPointer_t; + ImplPointer_t m_pImpl; + + bool createCheckbox(uno::Reference<text::XTextRange> xTextRange, + const ::rtl::OUString & rControlName); +}; + +} +} + +#endif // INCLUDED_FORM_CONTROL_HELPER_HXX diff --git a/writerfilter/source/dmapper/PropertyIds.cxx b/writerfilter/source/dmapper/PropertyIds.cxx index fb99f254ef86..abb2ca46a9c9 100644 --- a/writerfilter/source/dmapper/PropertyIds.cxx +++ b/writerfilter/source/dmapper/PropertyIds.cxx @@ -320,6 +320,8 @@ const rtl::OUString& PropertyNameSupplier::GetName( PropertyIds eId ) const case PROP_OUTLINE_LEVEL : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("OutlineLevel")); break; case PROP_LISTTAB_STOP_POSITION : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ListtabStopPosition")); break; case PROP_POSITION_AND_SPACE_MODE : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("PositionAndSpaceMode")); break; + case PROP_PARA_SPLIT: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("ParaSplit")); break; + case PROP_HELP: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("Help")); break; case PROP_HEADING_STYLE_NAME: sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("HeadingStyleName")); break; // case : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")); break; // case : sName = ::rtl::OUString(RTL_CONSTASCII_USTRINGPARAM("")); break; diff --git a/writerfilter/source/dmapper/PropertyIds.hxx b/writerfilter/source/dmapper/PropertyIds.hxx index 1d5992cc212c..2066cf58f530 100644 --- a/writerfilter/source/dmapper/PropertyIds.hxx +++ b/writerfilter/source/dmapper/PropertyIds.hxx @@ -284,6 +284,8 @@ enum PropertyIds /*248*/ ,PROP_LISTTAB_STOP_POSITION /*249*/ ,PROP_POSITION_AND_SPACE_MODE /*250*/ ,PROP_HEADING_STYLE_NAME +/*251*/ ,PROP_PARA_SPLIT +/*252*/ ,PROP_HELP }; struct PropertyNameSupplier_Impl; class PropertyNameSupplier diff --git a/writerfilter/source/dmapper/PropertyMap.cxx b/writerfilter/source/dmapper/PropertyMap.cxx index aa8a29c5e6a2..11930fb01972 100644 --- a/writerfilter/source/dmapper/PropertyMap.cxx +++ b/writerfilter/source/dmapper/PropertyMap.cxx @@ -40,6 +40,7 @@ #include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/text/XTextColumns.hpp> #include <com/sun/star/text/XText.hpp> +#include <com/sun/star/text/TextGridMode.hpp> #include <com/sun/star/text/XTextCopy.hpp> #include "dmapperLoggers.hxx" #include "PropertyMapHelper.hxx" @@ -155,6 +156,18 @@ XMLTag::Pointer_t PropertyMap::toTag() const sal_Int32 aInt; aMapIter->second >>= aInt; pTag->addAttr("value", aInt); + + sal_uInt32 auInt; + aMapIter->second >>= auInt; + pTag->addAttr("unsignedValue", auInt); + + float aFloat; + aMapIter->second >>= aFloat; + pTag->addAttr("floatValue", aFloat); + + ::rtl::OUString aStr; + aMapIter->second >>= auInt; + pTag->addAttr("stringValue", aStr); } catch (...) { } @@ -244,6 +257,7 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) : ,m_nDzaGutter( 0 ) ,m_bGutterRTL( false ) ,m_bSFBiDi( false ) + ,m_nGridType(0) ,m_nGridLinePitch( 1 ) ,m_nDxtCharSpace( 0 ) ,m_nLnnMod( 0 ) @@ -274,7 +288,7 @@ SectionPropertyMap::SectionPropertyMap(bool bIsFirstSection) : uno::Any aFalse( ::uno::makeAny( false ) ); Insert( PROP_GRID_DISPLAY, false, aFalse); Insert( PROP_GRID_PRINT, false, aFalse); - + Insert( PROP_GRID_MODE, false, uno::makeAny(text::TextGridMode::NONE)); if( m_bIsFirstSection ) @@ -908,6 +922,22 @@ void SectionPropertyMap::CloseSectionGroup( DomainMapper_Impl& rDM_Impl ) nRubyHeight = 0; operator[]( PropertyDefinition( PROP_GRID_RUBY_HEIGHT, false )) = uno::makeAny( nRubyHeight ); + sal_Int16 nGridMode = text::TextGridMode::NONE; + + switch (m_nGridType) + { + case NS_ooxml::LN_Value_wordprocessingml_ST_DocGrid_lines: + nGridMode = text::TextGridMode::LINES; + break; + case NS_ooxml::LN_Value_wordprocessingml_ST_DocGrid_linesAndChars: + nGridMode = text::TextGridMode::LINES_AND_CHARS; + break; + default: + break; + } + + operator[](PropertyDefinition(PROP_GRID_MODE, false)) = uno::makeAny(nGridMode); + _ApplyProperties( xFollowPageStyle ); //todo: creating a "First Page" style depends on HasTitlePage und _fFacingPage_ diff --git a/writerfilter/source/dmapper/PropertyMap.hxx b/writerfilter/source/dmapper/PropertyMap.hxx index 0efe7e3ba433..16886530f324 100644 --- a/writerfilter/source/dmapper/PropertyMap.hxx +++ b/writerfilter/source/dmapper/PropertyMap.hxx @@ -193,6 +193,7 @@ class SectionPropertyMap : public PropertyMap bool m_bGutterRTL; bool m_bSFBiDi; + sal_Int32 m_nGridType; sal_Int32 m_nGridLinePitch; sal_Int32 m_nDxtCharSpace; @@ -266,6 +267,7 @@ public: void SetDzaGutter( sal_Int32 nSet ) {m_nDzaGutter = nSet; } void SetSFBiDi( bool bSet ) { m_bSFBiDi = bSet;} + void SetGridType(sal_Int32 nSet) { m_nGridType = nSet; } void SetGridLinePitch( sal_Int32 nSet ) { m_nGridLinePitch = nSet; } void SetDxtCharSpace( sal_Int32 nSet ) { m_nDxtCharSpace = nSet; } diff --git a/writerfilter/source/dmapper/PropertyMapHelper.cxx b/writerfilter/source/dmapper/PropertyMapHelper.cxx index 555003774113..4fb4c759289d 100644 --- a/writerfilter/source/dmapper/PropertyMapHelper.cxx +++ b/writerfilter/source/dmapper/PropertyMapHelper.cxx @@ -32,6 +32,7 @@ #include <resourcemodel/TagLogger.hxx> #include "PropertyMapHelper.hxx" +#ifdef DEBUG namespace writerfilter { namespace dmapper @@ -39,7 +40,7 @@ namespace dmapper using namespace ::com::sun::star; - XMLTag::Pointer_t lcl_TableColumnSeparatorsToTag(const uno::Any & rTableColumnSeparators) +XMLTag::Pointer_t lcl_TableColumnSeparatorsToTag(const uno::Any & rTableColumnSeparators) { uno::Sequence<text::TableColumnSeparator> aSeq; rTableColumnSeparators >>= aSeq; @@ -127,3 +128,4 @@ XMLTag::Pointer_t lcl_PropertyValueSeqSeqToTag(PropertyValueSeqSeq_t rPropValSeq } } +#endif // DEBUG diff --git a/writerfilter/source/dmapper/PropertyMapHelper.hxx b/writerfilter/source/dmapper/PropertyMapHelper.hxx index fc9ea0a85bb4..4a528f1736c0 100644 --- a/writerfilter/source/dmapper/PropertyMapHelper.hxx +++ b/writerfilter/source/dmapper/PropertyMapHelper.hxx @@ -28,6 +28,7 @@ * ************************************************************************/ +#ifdef DEBUG #include "PropertyMap.hxx" #include <com/sun/star/beans/PropertyValues.hpp> @@ -46,3 +47,4 @@ typedef uno::Sequence<PropertyValueSeq_t> PropertyValueSeqSeq_t; XMLTag::Pointer_t lcl_PropertyValueSeqSeqToTag(PropertyValueSeqSeq_t & rPropValSeqSeq); } } +#endif // DEBUG diff --git a/writerfilter/source/dmapper/SettingsTable.cxx b/writerfilter/source/dmapper/SettingsTable.cxx index deb65c7c8cba..e711240b65d0 100644 --- a/writerfilter/source/dmapper/SettingsTable.cxx +++ b/writerfilter/source/dmapper/SettingsTable.cxx @@ -28,6 +28,7 @@ * ************************************************************************/ +#include <resourcemodel/ResourceModelHelper.hxx> #include <com/sun/star/beans/XPropertySet.hpp> #include <SettingsTable.hxx> @@ -37,7 +38,15 @@ #include <ConversionHelper.hxx> #include <rtl/ustring.hxx> +#ifdef DEBUG_DOMAINMAPPER +#include <resourcemodel/QNameToString.hxx> +#include "dmapperLoggers.hxx" +#endif + namespace writerfilter { + +using resourcemodel::resolveSprmProps; + namespace dmapper { @@ -56,6 +65,21 @@ struct SettingsTable_Impl bool m_bNoPunctuationKerning; bool m_doNotIncludeSubdocsInStats; // Do Not Include Content in Text Boxes, Footnotes, and Endnotes in Document Statistics) bool m_bRecordChanges; + int m_nEdit; + bool m_bFormatting; + bool m_bEnforcement; + int m_nCryptProviderType; + int m_nCryptAlgorithmClass; + int m_nCryptAlgorithmType; + ::rtl::OUString m_sCryptAlgorithmSid; + int m_nCryptSpinCount; + ::rtl::OUString m_sCryptProvider; + ::rtl::OUString m_sAlgIdExt; + ::rtl::OUString m_sAlgIdExtSource; + ::rtl::OUString m_sCryptProviderTypeExt; + ::rtl::OUString m_sCryptProviderTypeExtSource; + ::rtl::OUString m_sHash; + ::rtl::OUString m_sSalt; SettingsTable_Impl( DomainMapper& rDMapper, const uno::Reference< lang::XMultiServiceFactory > xTextFactory ) : m_rDMapper( rDMapper ) @@ -65,6 +89,13 @@ struct SettingsTable_Impl , m_bNoPunctuationKerning(false) , m_doNotIncludeSubdocsInStats(false) , m_bRecordChanges(false) + , m_nEdit(NS_ooxml::LN_Value_wordprocessingml_ST_DocProtect_none) + , m_bFormatting(false) + , m_bEnforcement(false) + , m_nCryptProviderType(NS_ooxml::LN_Value_wordprocessingml_ST_CryptProv_rsaAES) + , m_nCryptAlgorithmClass(NS_ooxml::LN_Value_wordprocessingml_ST_AlgClass_hash) + , m_nCryptAlgorithmType(NS_ooxml::LN_Value_wordprocessingml_ST_AlgType_typeAny) + , m_nCryptSpinCount(0) {} }; @@ -79,8 +110,15 @@ SettingsTable::~SettingsTable() delete m_pImpl; } -void SettingsTable::attribute(Id /*Name*/, Value & val) +void SettingsTable::attribute(Id nName, Value & val) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("SettingsTable.attribute"); + dmapper_logger->attribute("name", (*QNameToString::Instance())(nName)); + dmapper_logger->attribute("value", val.toString()); +#endif + + (void) nName; int nIntValue = val.getInt(); (void)nIntValue; ::rtl::OUString sValue = val.getString(); @@ -99,10 +137,18 @@ void SettingsTable::attribute(Id /*Name*/, Value & val) } } #endif +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("SettingsTable.attribute"); +#endif } void SettingsTable::sprm(Sprm& rSprm) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("SettingsTable.sprm"); + dmapper_logger->chars(rSprm.toString()); +#endif + sal_uInt32 nSprmId = rSprm.getId(); Value::Pointer_t pValue = rSprm.getValue(); @@ -184,11 +230,20 @@ void SettingsTable::sprm(Sprm& rSprm) m_pImpl->m_bRecordChanges = bool(rSprm.getValue( )->getInt( ) ); } break; + case NS_ooxml::LN_CT_Settings_documentProtection: + { + resolveSprmProps(*this, rSprm); + } + break; default: { OSL_ENSURE( false, "unknown sprmid in SettingsTable::sprm()"); } } + +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("SettingsTable.sprm"); +#endif } void SettingsTable::entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref) diff --git a/writerfilter/source/dmapper/StyleSheetTable.cxx b/writerfilter/source/dmapper/StyleSheetTable.cxx index 8b2dbc4d9756..5f2e2268abb8 100644 --- a/writerfilter/source/dmapper/StyleSheetTable.cxx +++ b/writerfilter/source/dmapper/StyleSheetTable.cxx @@ -417,6 +417,7 @@ void StyleSheetTable::attribute(Id Name, Value & val) #ifdef DEBUG_DOMAINMAPPER dmapper_logger->startElement("StyleSheetTable.attribute"); dmapper_logger->attribute("name", (*QNameToString::Instance())(Name)); + dmapper_logger->attribute("value", val.toString()); #endif OSL_ENSURE( m_pImpl->m_pCurrentEntry, "current entry has to be set here"); @@ -534,10 +535,9 @@ void StyleSheetTable::attribute(Id Name, Value & val) break; default: { - //----> debug - int nVal = val.getInt(); - ++nVal; - //<---- debug +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("unhandled"); +#endif } break; } @@ -599,7 +599,6 @@ void StyleSheetTable::sprm(Sprm & rSprm) break; case NS_ooxml::LN_CT_Style_tblPr: //contains table properties case NS_ooxml::LN_CT_Style_tblStylePr: //contains to table properties - case NS_ooxml::LN_CT_DocDefaults_pPrDefault: case NS_ooxml::LN_CT_DocDefaults_rPrDefault: case NS_ooxml::LN_CT_TblPrBase_tblInd: //table properties - at least width value and type case NS_ooxml::LN_EG_RPrBase_rFonts: //table fonts @@ -682,19 +681,30 @@ void StyleSheetTable::sprm(Sprm & rSprm) break; case NS_ooxml::LN_CT_Style_pPr: /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */ + // no break case NS_ooxml::LN_CT_Style_rPr: /* WRITERFILTERSTATUS: done: 100, planned: 0, spent: 0 */ + // no break default: - if (!m_pImpl->m_pCurrentEntry) - break; - TablePropertiesHandlerPtr pTblHandler( new TablePropertiesHandler( true ) ); - pTblHandler->SetProperties( m_pImpl->m_pCurrentEntry->pProperties ); - if ( !pTblHandler->sprm( rSprm ) ) { - m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties ); - m_pImpl->m_rDMapper.sprm( rSprm ); - m_pImpl->m_rDMapper.PopStyleSheetProperties( ); + if (!m_pImpl->m_pCurrentEntry) + break; + + TablePropertiesHandlerPtr pTblHandler( new TablePropertiesHandler( true ) ); + pTblHandler->SetProperties( m_pImpl->m_pCurrentEntry->pProperties ); + if ( !pTblHandler->sprm( rSprm ) ) + { + m_pImpl->m_rDMapper.PushStyleSheetProperties( m_pImpl->m_pCurrentEntry->pProperties ); + + PropertyMapPtr pProps(new PropertyMap()); + m_pImpl->m_rDMapper.sprm( rSprm, pProps ); + + m_pImpl->m_pCurrentEntry->pProperties->insert(pProps); + + m_pImpl->m_rDMapper.PopStyleSheetProperties( ); + } } + break; } #ifdef DEBUG_DOMAINMAPPER @@ -798,6 +808,10 @@ uno::Sequence< ::rtl::OUString > PropValVector::getNames() -----------------------------------------------------------------------*/ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("applyStyleSheets"); +#endif + try { uno::Reference< style::XStyleFamiliesSupplier > xStylesSupplier( m_pImpl->m_xTextDocument, uno::UNO_QUERY_THROW ); @@ -956,11 +970,24 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) PropValVector aSortedPropVals; for( sal_Int32 nProp = 0; nProp < aPropValues.getLength(); ++nProp) { - // Don't add the style name properties +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("propvalue"); + dmapper_logger->attribute("name", aPropValues[nProp].Name); + dmapper_logger->attribute("value", aPropValues[nProp].Value); +#endif + // Don't add the style name properties bool bIsParaStyleName = aPropValues[nProp].Name.equalsAscii( "ParaStyleName" ); bool bIsCharStyleName = aPropValues[nProp].Name.equalsAscii( "CharStyleName" ); - if ( !bInsert && !bIsParaStyleName && !bIsCharStyleName ) + if ( !bIsParaStyleName && !bIsCharStyleName ) + { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("insert"); +#endif aSortedPropVals.Insert( aPropValues[nProp] ); + } +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("propvalue"); +#endif } if(bAddFollowStyle) { @@ -1009,7 +1036,15 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) } } if(bInsert) + { xStyles->insertByName( sConvertedStyleName, uno::makeAny( xStyle) ); +#ifdef DEBUG_DOMAINMAPPER + uno::Reference<beans::XPropertySet> xProps(xStyle, uno::UNO_QUERY); + dmapper_logger->startElement("insertStyle"); + dmapper_logger->addTag(unoPropertySetToTag(xProps)); + dmapper_logger->endElement("insertStyle"); +#endif + } } ++aIt; } @@ -1020,6 +1055,10 @@ void StyleSheetTable::ApplyStyleSheets( FontTablePtr rFontTable ) (void)rEx; OSL_ENSURE( false, "Styles could not be imported completely"); } + +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("applyStyleSheets"); +#endif } /*-- 22.06.2006 15:56:56--------------------------------------------------- diff --git a/writerfilter/source/dmapper/ThemeTable.cxx b/writerfilter/source/dmapper/ThemeTable.cxx index ec9d8ea9d5a5..0f0becf06552 100755..100644 --- a/writerfilter/source/dmapper/ThemeTable.cxx +++ b/writerfilter/source/dmapper/ThemeTable.cxx @@ -31,6 +31,10 @@ #include <ooxml/resourceids.hxx> #endif #include <stdio.h> +#ifdef DEBUG_DOMAINMAPPER +#include "dmapperLoggers.hxx" +#include <resourcemodel/QNameToString.hxx> +#endif namespace writerfilter { namespace dmapper @@ -59,6 +63,11 @@ ThemeTable::~ThemeTable() void ThemeTable::attribute(Id Name, Value & val) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("ThemeTable.attribute"); + dmapper_logger->attribute("name", (*QNameToString::Instance())(Name)); + dmapper_logger->attribute("value", val.toString()); +#endif // int nIntValue = val.getInt(); ::rtl::OUString sValue = val.getString(); // printf ( "ThemeTable::attribute(0x%.4x, 0x%.4x) [%s]\n", (unsigned int)Name, (unsigned int)nIntValue, ::rtl::OUStringToOString(sValue, RTL_TEXTENCODING_DONTKNOW).getStr()); @@ -72,12 +81,23 @@ void ThemeTable::attribute(Id Name, Value & val) break; default: { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("unhandled"); +#endif } } +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("ThemeTable.attribute"); +#endif } void ThemeTable::sprm(Sprm& rSprm) { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("ThemeTable.sprm"); + dmapper_logger->chars(rSprm.toString()); +#endif + sal_uInt32 nSprmId = rSprm.getId(); (void)nSprmId; @@ -126,14 +146,27 @@ void ThemeTable::sprm(Sprm& rSprm) break; default: { +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->element("unhandled"); +#endif } } +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("ThemeTable.sprm"); +#endif } void ThemeTable::entry(int /*pos*/, writerfilter::Reference<Properties>::Pointer_t ref) { - // printf ( "ThemeTable::entry\n"); +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->startElement("ThemeTable.entry"); +#endif + ref->resolve(*this); + +#ifdef DEBUG_DOMAINMAPPER + dmapper_logger->endElement("ThemeTable.entry"); +#endif } const ::rtl::OUString ThemeTable::getFontNameForTheme(const Id id) const diff --git a/writerfilter/source/dmapper/dmapperLoggers.hxx b/writerfilter/source/dmapper/dmapperLoggers.hxx index a19ff4832370..fd9ed722de4a 100644 --- a/writerfilter/source/dmapper/dmapperLoggers.hxx +++ b/writerfilter/source/dmapper/dmapperLoggers.hxx @@ -31,6 +31,7 @@ #ifndef INCLUDED_DMAPPER_LOGGERS_HXX #define INCLUDED_DMAPPER_LOGGERS_HXX +#ifdef DEBUG #include <resourcemodel/TagLogger.hxx> namespace writerfilter { @@ -38,4 +39,5 @@ namespace writerfilter { extern TagLogger::Pointer_t dmapper_logger; } } +#endif // DEBUG #endif // INCLUDED_DMAPPER_LOGGERS_HXX diff --git a/writerfilter/source/dmapper/genclass.xsl b/writerfilter/source/dmapper/genclass.xsl new file mode 100644 index 000000000000..eaddab52ea0e --- /dev/null +++ b/writerfilter/source/dmapper/genclass.xsl @@ -0,0 +1,707 @@ +<?xml version="1.0" encoding="utf-8"?> +<xsl:stylesheet + version="1.0" + xmlns:xsl="http://www.w3.org/1999/XSL/Transform" + xmlns:rng="http://relaxng.org/ns/structure/1.0" + xmlns:xalan="http://xml.apache.org/xalan" + exclude-result-prefixes = "xalan" + xml:indent="true"> + <xsl:output method="text" version="1.0" encoding="UTF-8" indent="yes" omit-xml-declaration="no"/> + + <xsl:template match="/"> + <xsl:for-each select="/model/class"> + <xsl:choose> + <xsl:when test="$filetype='inc'"> + <xsl:call-template name="incfile"/> + </xsl:when> + <xsl:when test="$filetype='impl'"> + <xsl:call-template name="implfile"/> + </xsl:when> + </xsl:choose> + </xsl:for-each> + </xsl:template> + + <xsl:template name="license"> + <xsl:text>/************************************************************************* + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright 2008 by Sun Microsystems, Inc. + * + * OpenOffice.org - a multi-platform office productivity suite + * + * $RCSfile: PropertyMap.hxx,v $ + * $Revision: 1.18 $ + * + * This file is part of OpenOffice.org. + * + * OpenOffice.org is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License version 3 + * only, as published by the Free Software Foundation. + * + * OpenOffice.org is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License version 3 for more details + * (a copy is included in the LICENSE file that accompanied this code). + * + * You should have received a copy of the GNU Lesser General Public License + * version 3 along with OpenOffice.org. If not, see + * <http://www.openoffice.org/license.html> + * for a copy of the LGPLv3 License. + * + ************************************************************************/
</xsl:text> + </xsl:template> + + <xsl:template name="memberid"> + <xsl:variable name="member"> + <xsl:choose> + <xsl:when test="@member"> + <xsl:value-of select="@member"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:for-each select="ancestor::class/member[@name=$member]"> + <xsl:choose> + <xsl:when test="@type='bool'"> + <xsl:text>m_b</xsl:text> + </xsl:when> + <xsl:when test="@type='OUString'"> + <xsl:text>m_s</xsl:text> + </xsl:when> + <xsl:when test="@type='sal_uInt32'"> + <xsl:text>m_n</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:text>m_</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:for-each> + <xsl:call-template name="capfirst"> + <xsl:with-param name="string" select="$member"/> + </xsl:call-template> + </xsl:template> + + <xsl:template name="incfile"> + <xsl:call-template name="license"/> + <xsl:for-each select="//class"> + <xsl:variable name="includeguard"> + <xsl:text>INCLUDED_</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>_HXX</xsl:text> + </xsl:variable> + <xsl:text>#ifndef </xsl:text> + <xsl:value-of select="$includeguard"/> + <xsl:text>
#define </xsl:text> + <xsl:value-of select="$includeguard"/> + <xsl:text>
#include <resourcemodel/WW8ResourceModel.hxx></xsl:text> + <xsl:text>
#include <rtl/ustring.hxx></xsl:text> + <xsl:text>
namespace writerfilter {</xsl:text> + <xsl:text>
namespace dmapper {</xsl:text> + <xsl:call-template name="classdecl"/> + <xsl:text>
}}</xsl:text> + <xsl:text>
#endif //</xsl:text> + <xsl:value-of select="$includeguard"/> + <xsl:text>
</xsl:text> + </xsl:for-each> + </xsl:template> + + <xsl:template name="implfile"> + <xsl:call-template name="license"/> + <xsl:for-each select="//class"> + <xsl:text>#include "</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>.hxx"
</xsl:text> + <xsl:text>
#include <ooxml/resourceids.hxx></xsl:text> + <xsl:text>
#ifdef DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
#include <resourcemodel/QNameToString.hxx></xsl:text> + <xsl:text>
#include "dmapperLoggers.hxx"</xsl:text> + <xsl:text>
#endif</xsl:text> + <xsl:text>
namespace writerfilter {</xsl:text> + <xsl:text>
namespace dmapper {
</xsl:text> + <xsl:call-template name="classimpl"/> + <xsl:text>}}
</xsl:text> + </xsl:for-each> + </xsl:template> + + <xsl:template name="classdecl"> + <xsl:text>
class </xsl:text> + <xsl:value-of select="@name"/> + <xsl:if test="parent"> + <xsl:text> : public </xsl:text> + </xsl:if> + <xsl:for-each select="parent"> + <xsl:if test="position() > 1"> + <xsl:text>, </xsl:text> + </xsl:if> + <xsl:value-of select="@name"/> + </xsl:for-each> + <xsl:text>
{</xsl:text> + <xsl:text>
public:</xsl:text> + <xsl:call-template name="typedefs"/> + <xsl:text>
 // constructor</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>();</xsl:text> + <xsl:text>
 // destructor</xsl:text> + <xsl:text>
 virtual ~</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>();
</xsl:text> + <xsl:call-template name="memberfuncdecls"/> + <xsl:for-each select="sprm"> + <xsl:text>
 // sprm</xsl:text> + <xsl:text>
 void sprm(Sprm & r_sprm);</xsl:text> + <xsl:text>
 void resolveSprm(Sprm & r_sprm);
</xsl:text> + </xsl:for-each> + <xsl:for-each select="attribute"> + <xsl:text>
 // attribute</xsl:text> + <xsl:text>
 void attribute(Id name, Value & val);
</xsl:text> + </xsl:for-each> + <xsl:text>
private:</xsl:text> + <xsl:call-template name="memberdecls"/> + <xsl:text>
};

</xsl:text> + </xsl:template> + + <xsl:template name="type"> + <xsl:param name="name"/> + <xsl:choose> + <xsl:when test="$name='OUString'"> + <xsl:text>::rtl::OUString</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="$name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="typedefs"> + <xsl:text>
 // typedefs</xsl:text> + <xsl:for-each select="typedef"> + <xsl:text>
 typedef </xsl:text> + <xsl:choose> + <xsl:when test="@type = 'shared_ptr'"> + <xsl:text>::boost::shared_ptr<</xsl:text> + <xsl:value-of select="ancestor::class/@name"/> + <xsl:text>></xsl:text> + </xsl:when> + <xsl:otherwise> + </xsl:otherwise> + </xsl:choose> + <xsl:for-each select="vector"> + <xsl:text>::std::vector<</xsl:text> + <xsl:call-template name="cctype"/> + <xsl:text>></xsl:text> + </xsl:for-each> + <xsl:text> </xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>;</xsl:text> + </xsl:for-each> + <xsl:text>
</xsl:text> + </xsl:template> + + <xsl:template name="settername"> + <xsl:text>set</xsl:text> + <xsl:call-template name="capfirst"> + <xsl:with-param name="string" select="@name"/> + </xsl:call-template> + </xsl:template> + + <xsl:template name="gettername"> + <xsl:text>get</xsl:text> + <xsl:call-template name="capfirst"> + <xsl:with-param name="string" select="@name"/> + </xsl:call-template> + </xsl:template> + + <xsl:template name="pushbackname"> + <xsl:value-of select="@name"/> + <xsl:text>PushBack</xsl:text> + </xsl:template> + + <xsl:template name="settersig"> + <xsl:param name="classname"/> + <xsl:variable name="impl"> + <xsl:if test="string-length($classname) > 0"> + <xsl:text>true</xsl:text> + </xsl:if> + </xsl:variable> + <xsl:text>void </xsl:text> + <xsl:if test="string-length($classname) > 0"> + <xsl:value-of select="$classname"/> + <xsl:text>::</xsl:text> + </xsl:if> + <xsl:call-template name="settername"/> + <xsl:text>(</xsl:text> + <xsl:call-template name="constcctyperef"> + <xsl:with-param name="impl" select="$impl"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:call-template name="paramname"/> + <xsl:text>)</xsl:text> + </xsl:template> + + <xsl:template name="gettersig"> + <xsl:param name="classname"/> + <xsl:variable name="impl"> + <xsl:if test="string-length($classname) > 0"> + <xsl:text>true</xsl:text> + </xsl:if> + </xsl:variable> + <xsl:variable name="type" select="@type"/> + <xsl:call-template name="constcctyperef"> + <xsl:with-param name="impl" select="$impl"/> + </xsl:call-template> + <xsl:text> </xsl:text> + <xsl:if test="string-length($classname) > 0"> + <xsl:value-of select="$classname"/> + <xsl:text>::</xsl:text> + </xsl:if> + <xsl:call-template name="gettername"/> + <xsl:text>() const</xsl:text> + </xsl:template> + + <xsl:template name="pushbacksig"> + <xsl:param name="classname"/> + <xsl:variable name="pushback"> + <xsl:call-template name="pushbackname"/> + </xsl:variable> + <xsl:variable name="type" select="@type"/> + <xsl:for-each select="ancestor::class/typedef[@name=$type]"> + <xsl:for-each select="vector"> + <xsl:text>void </xsl:text> + <xsl:if test="string-length($classname) > 0"> + <xsl:value-of select="$classname"/> + <xsl:text>::</xsl:text> + </xsl:if> + <xsl:value-of select="$pushback"/> + <xsl:text>(</xsl:text> + <xsl:call-template name="constcctyperef"> + <xsl:with-param name="deep">true</xsl:with-param> + </xsl:call-template> + <xsl:text> r_Element</xsl:text> + <xsl:text>)</xsl:text> + </xsl:for-each> + </xsl:for-each> + </xsl:template> + + <xsl:template name="memberfuncdecls"> + <xsl:for-each select="member"> + <xsl:text>
 // member: </xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>
 </xsl:text> + <xsl:call-template name="settersig"/> + <xsl:text>;</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:call-template name="gettersig"/> + <xsl:text>;
 </xsl:text> + <xsl:variable name="pushback"> + <xsl:call-template name="pushbacksig"/> + </xsl:variable> + <xsl:if test="string-length($pushback) > 0"> + <xsl:value-of select="$pushback"/> + <xsl:text>;
</xsl:text> + </xsl:if> + </xsl:for-each> + </xsl:template> + + <xsl:template name="memberdecls"> + <xsl:for-each select="member"> + <xsl:text>
 </xsl:text> + <xsl:call-template name="cctype"/> + <xsl:text> </xsl:text> + <xsl:call-template name="memberid"/> + <xsl:text>;</xsl:text> + </xsl:for-each> + </xsl:template> + + <xsl:template name="cctype"> + <xsl:param name="deep"/> + <xsl:param name="impl"/> + <xsl:variable name="type" select="@type"/> + <xsl:variable name="try1"> + <xsl:if test="$deep='true'"> + <xsl:for-each select="ancestor::class/typedef[@name=$type]"> + <xsl:for-each select="vector"> + <xsl:call-template name="cctype"> + <xsl:with-param name="impl" select="$impl"/> + <xsl:with-param name="deep" select="$deep"/> + </xsl:call-template> + </xsl:for-each> + </xsl:for-each> + </xsl:if> + </xsl:variable> + <xsl:choose> + <xsl:when test="string-length($try1) > 0"> + <xsl:value-of select="$try1"/> + </xsl:when> + <xsl:when test="@type='OUString'"> + <xsl:text>rtl::OUString</xsl:text> + </xsl:when> + <xsl:otherwise> + <xsl:if test="$impl='true'"> + <xsl:for-each select="ancestor::class"> + <xsl:variable name="classname" select="@name"/> + <xsl:for-each select="typedef[@name=$type]"> + <xsl:value-of select="$classname"/> + <xsl:text>::</xsl:text> + </xsl:for-each> + </xsl:for-each> + </xsl:if> + <xsl:value-of select="@type"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="constcctype"> + <xsl:param name="impl"/> + <xsl:choose> + <xsl:when test="@type='bool' or @type='sal_uInt32'"> + <xsl:value-of select="@type"/> + </xsl:when> + <xsl:otherwise> + <xsl:text>const </xsl:text> + <xsl:call-template name="cctype"> + <xsl:with-param name="impl" select="$impl"/> + </xsl:call-template> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="constcctyperef"> + <xsl:param name="impl"/> + <xsl:choose> + <xsl:when test="@type='bool' or @type='sal_uInt32'"> + <xsl:value-of select="@type"/> + </xsl:when> + <xsl:otherwise> + <xsl:call-template name="constcctype"> + <xsl:with-param name="impl" select="$impl"/> + </xsl:call-template> + <xsl:text> &</xsl:text> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="capfirst"> + <xsl:param name="string"/> + <xsl:variable name="first" select="translate(substring($string, 1,1), 'abcdefghijklmnopqrstuvwxyz', 'ABCDEFGHIJKLMNOPQRSTUVWXYZ')"/> + <xsl:value-of select="concat($first, substring($string, 2))"/> + </xsl:template> + + <xsl:template name="paramname"> + <xsl:choose> + <xsl:when test="@type='OUString'"> + <xsl:text>r_s</xsl:text> + <xsl:call-template name="capfirst"> + <xsl:with-param name="string" select="@name"/> + </xsl:call-template> + </xsl:when> + <xsl:otherwise> + <xsl:text>r_</xsl:text> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:template> + + <xsl:template name="setterimpl"> + <xsl:call-template name="settersig"> + <xsl:with-param name="classname" select="ancestor::class/@name"/> + </xsl:call-template> + <xsl:text>
{</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:call-template name="memberid"/> + <xsl:text> = </xsl:text> + <xsl:call-template name="paramname"/> + <xsl:text>;</xsl:text> + <xsl:text>
}

</xsl:text> + </xsl:template> + + <xsl:template name="getterimpl"> + <xsl:call-template name="gettersig"> + <xsl:with-param name="classname" select="ancestor::class/@name"/> + </xsl:call-template> + <xsl:text>
{</xsl:text> + <xsl:text>
 return </xsl:text> + <xsl:call-template name="memberid"/> + <xsl:text>;</xsl:text> + <xsl:text>
}

</xsl:text> + </xsl:template> + + <xsl:template name="pushbackimpl"> + <xsl:variable name="sig"> + <xsl:call-template name="pushbacksig"> + <xsl:with-param name="classname" select="ancestor::class/@name"/> + </xsl:call-template> + </xsl:variable> + <xsl:if test="string-length($sig) > 0"> + <xsl:value-of select="$sig"/> + <xsl:text>
{</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:call-template name="memberid"/> + <xsl:text>.push_back(r_Element);</xsl:text> + <xsl:text>
}

</xsl:text> + </xsl:if> + </xsl:template> + + <xsl:template name="getvalue"> + <xsl:param name="valuePrefix"/> + <xsl:choose> + <xsl:when test="@type='OUString'"> + <xsl:value-of select="$valuePrefix"/> + <xsl:text>getString()</xsl:text> + </xsl:when> + <xsl:when test="@type='bool' or @type='sal_uInt32'"> + <xsl:value-of select="$valuePrefix"/> + <xsl:text>getInt()</xsl:text> + </xsl:when> + <xsl:when test="@type"> + <xsl:variable name="type" select="@type"/> + <xsl:for-each select="ancestor::class/typedef[@name=$type]"> + <xsl:call-template name="getvalue"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + </xsl:for-each> + </xsl:when> + <xsl:otherwise> + <xsl:variable name="member"> + <xsl:choose> + <xsl:when test="@member"> + <xsl:value-of select="@member"/> + </xsl:when> + <xsl:otherwise> + <xsl:value-of select="@name"/> + </xsl:otherwise> + </xsl:choose> + </xsl:variable> + <xsl:for-each select="ancestor::class/member[@name=$member]"> + <xsl:call-template name="getvalue"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + </xsl:for-each> + </xsl:otherwise> + </xsl:choose> + <xsl:for-each select="vector"> + <xsl:call-template name="getvalue"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + </xsl:for-each> + </xsl:template> + + <xsl:template name="sprmactionset"> + <xsl:param name="valuePrefix"/> + <xsl:text>
 {</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:call-template name="memberid"/> + <xsl:text> = </xsl:text> + <xsl:call-template name="getvalue"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + <xsl:text>;
 }</xsl:text> + </xsl:template> + + <xsl:template name="sprmactionpushback"> + <xsl:param name="valuePrefix"/> + <xsl:text>
 {</xsl:text> + <xsl:text>
 </xsl:text> + <xsl:call-template name="memberid"/> + <xsl:text>.push_back(</xsl:text> + <xsl:call-template name="getvalue"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + <xsl:text>);</xsl:text> + <xsl:text>;
 }</xsl:text> + </xsl:template> + + <xsl:template name="sprmactionresolve"> + <xsl:text>
 {</xsl:text> + <xsl:text>
 resolveSprm(r_Sprm);</xsl:text> + <xsl:text>
 }</xsl:text> + </xsl:template> + + <xsl:template name="sprmaction"> + <xsl:param name="valuePrefix"/> + <xsl:choose> + <xsl:when test="@action='set'"> + <xsl:call-template name="sprmactionset"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="@action='pushback'"> + <xsl:call-template name="sprmactionpushback"> + <xsl:with-param name="valuePrefix" select="$valuePrefix"/> + </xsl:call-template> + </xsl:when> + <xsl:when test="@action='resolve'"> + <xsl:call-template name="sprmactionresolve"/> + </xsl:when> + <xsl:otherwise/> + </xsl:choose> + </xsl:template> + + <xsl:template name="sprmimpl"> + <xsl:for-each select="sprm"> + <xsl:text>
void </xsl:text> + <xsl:variable name="classname" select="ancestor::class/@name"/> + <xsl:value-of select="$classname"/> + <xsl:text>::sprm(Sprm & r_Sprm)</xsl:text> + <xsl:text>
{</xsl:text> + <xsl:text>
#ifdef DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 dmapper_logger->startElement("</xsl:text> + <xsl:value-of select="$classname"/> + <xsl:text>.sprm");</xsl:text> + <xsl:text>
 dmapper_logger->chars(r_Sprm.toString());</xsl:text> + <xsl:text>
#endif</xsl:text> + <xsl:text>
 switch(r_Sprm.getId())</xsl:text> + <xsl:text>
 {</xsl:text> + <xsl:for-each select="element"> + <xsl:text>
 case </xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>:</xsl:text> + <xsl:text>
 /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */</xsl:text> + <xsl:call-template name="sprmaction"> + <xsl:with-param name="valuePrefix">r_Sprm.getValue()-></xsl:with-param> + </xsl:call-template> + <xsl:text>
 break;</xsl:text> + </xsl:for-each> + <xsl:text>
 default:</xsl:text> + <xsl:text>
#ifdef DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 dmapper_logger->element("unhandled");</xsl:text> + <xsl:text>
#endif DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 break;</xsl:text> + <xsl:text>
 }</xsl:text> + <xsl:text>
#ifdef DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 dmapper_logger->endElement("</xsl:text> + <xsl:value-of select="$classname"/> + <xsl:text>.sprm");</xsl:text> + <xsl:text>
#endif</xsl:text> + <xsl:text>
}
</xsl:text> + <xsl:text>
void </xsl:text> + <xsl:value-of select="ancestor::class/@name"/> + <xsl:text>::resolveSprm(Sprm & r_Sprm)</xsl:text> + <xsl:text>
{</xsl:text> + <xsl:text>
 writerfilter::Reference<Properties>::Pointer_t pProperties = r_Sprm.getProps();</xsl:text> + <xsl:text>
 if( pProperties.get())</xsl:text> + <xsl:text>
 pProperties->resolve(*this);</xsl:text> + <xsl:text>
}
</xsl:text> + </xsl:for-each> + </xsl:template> + + <xsl:template name="attrimpl"> + <xsl:for-each select="attribute"> + <xsl:text>
void </xsl:text> + <xsl:variable name="classname" select="ancestor::class/@name"/> + <xsl:value-of select="$classname"/> + <xsl:text>::</xsl:text> + <xsl:text>attribute(Id name, Value & val)</xsl:text> + <xsl:text>
{</xsl:text> + <xsl:text>
#ifdef DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 dmapper_logger->startElement("</xsl:text> + <xsl:value-of select="$classname"/> + <xsl:text>.attribute");</xsl:text> + <xsl:text>
 dmapper_logger->attribute("name", (*QNameToString::Instance())(name));</xsl:text> + <xsl:text>
 dmapper_logger->attribute("value", val.toString());</xsl:text> + <xsl:text>
 dmapper_logger->endElement("</xsl:text> + <xsl:value-of select="$classname"/> + <xsl:text>.attribute");</xsl:text> + <xsl:text>
#endif</xsl:text> + <xsl:text>
 switch (name)</xsl:text> + <xsl:text>
 {</xsl:text> + <xsl:for-each select="attribute"> + <xsl:text>
 case </xsl:text> + <xsl:value-of select="@id"/> + <xsl:text>:</xsl:text> + <xsl:text>
 /* WRITERFILTERSTATUS done: 100, planned: 2, spent: 0 */</xsl:text> + <xsl:call-template name="sprmactionset"> + <xsl:with-param name="valuePrefix">val.</xsl:with-param> + </xsl:call-template> + <xsl:text>
 break;</xsl:text> + </xsl:for-each> + <xsl:text>
 default:</xsl:text> + <xsl:text>
#ifdef DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 dmapper_logger->element("unhandled");</xsl:text> + <xsl:text>
#endif DEBUG_DOMAINMAPPER</xsl:text> + <xsl:text>
 break;</xsl:text> + <xsl:text>
 }</xsl:text> + <xsl:text>
}

</xsl:text> + </xsl:for-each> + </xsl:template> + + <xsl:template name="constructorimpl"> + <xsl:text>
</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>::</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>()</xsl:text> + <xsl:variable name="memberinits"> + <xsl:for-each select="member[@type='sal_uInt32' or @type='bool']"> + <xsl:if test="position() > 1"> + <xsl:text>,</xsl:text> + <xsl:text>
 </xsl:text> + </xsl:if> + <xsl:call-template name="memberid"/> + <xsl:choose> + <xsl:when test="@type='sal_uInt32'"> + <xsl:text>(0)</xsl:text> + </xsl:when> + <xsl:when test="@type='bool'"> + <xsl:text>(false)</xsl:text> + </xsl:when> + </xsl:choose> + </xsl:for-each> + </xsl:variable> + <xsl:if test="string-length($memberinits) > 0"> + <xsl:text>
: </xsl:text> + <xsl:value-of select="$memberinits"/> + </xsl:if> + <xsl:text>
{</xsl:text> + <xsl:text>
}

</xsl:text> + </xsl:template> + + <xsl:template name="destructorimpl"> + <xsl:text>
</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>::~</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>()</xsl:text> + <xsl:text>
{</xsl:text> + <xsl:text>
}

</xsl:text> + </xsl:template> + + <xsl:template name="classimpl"> + <xsl:variable name="classname" select="@name"/> + <xsl:variable name="comment"> + <xsl:text>class: </xsl:text> + <xsl:value-of select="$classname"/> + </xsl:variable> + <xsl:variable name="commentfill"> + <xsl:value-of select="translate($comment, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ: ', + '******************************************************')"/> + </xsl:variable> + <xsl:text>
/***</xsl:text> + <xsl:value-of select="$commentfill"/> + <xsl:text>*</xsl:text> + <xsl:text>
 * </xsl:text> + <xsl:value-of select="$comment"/> + <xsl:text> *</xsl:text> + <xsl:text>
 **</xsl:text> + <xsl:value-of select="$commentfill"/> + <xsl:text>**/
</xsl:text> + <xsl:call-template name="constructorimpl"/> + <xsl:call-template name="destructorimpl"/> + <xsl:for-each select="member"> + <xsl:text>// member: </xsl:text> + <xsl:value-of select="$classname"/> + <xsl:text>::</xsl:text> + <xsl:value-of select="@name"/> + <xsl:text>
</xsl:text> + <xsl:call-template name="setterimpl"/> + <xsl:call-template name="getterimpl"/> + <xsl:call-template name="pushbackimpl"/> + </xsl:for-each> + <xsl:call-template name="sprmimpl"/> + <xsl:call-template name="attrimpl"/> + </xsl:template> +</xsl:stylesheet> diff --git a/writerfilter/source/dmapper/makefile.mk b/writerfilter/source/dmapper/makefile.mk index 4b9636855562..300dfb31d959 100644 --- a/writerfilter/source/dmapper/makefile.mk +++ b/writerfilter/source/dmapper/makefile.mk @@ -47,6 +47,8 @@ SLOFILES= \ $(SLO)$/DomainMapperTableHandler.obj \ $(SLO)$/DomainMapperTableManager.obj \ $(SLO)$/DomainMapper_Impl.obj \ + $(SLO)$/FFDataHandler.obj \ + $(SLO)$/FormControlHelper.obj \ $(SLO)$/FontTable.obj \ $(SLO)$/GraphicHelpers.obj \ $(SLO)$/GraphicImport.obj \ |