Kaydet (Commit) 597e2887 authored tarafından Oliver Specht's avatar Oliver Specht

footnote symbols completed, bookmarks added

üst 9a75e7a4
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: DomainMapper.cxx,v $ * $RCSfile: DomainMapper.cxx,v $
* *
* $Revision: 1.57 $ * $Revision: 1.58 $
* *
* last change: $Author: os $ $Date: 2007-06-06 06:33:22 $ * last change: $Author: os $ $Date: 2007-06-12 05:40:45 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -90,6 +90,7 @@ ...@@ -90,6 +90,7 @@
#ifndef _COM_SUN_STAR_TEXT_WRITINGMODE_HPP_ #ifndef _COM_SUN_STAR_TEXT_WRITINGMODE_HPP_
#include <com/sun/star/text/WritingMode.hpp> #include <com/sun/star/text/WritingMode.hpp>
#endif #endif
#include <com/sun/star/text/XFootnote.hpp>
#ifndef _COM_SUN_STAR_STYLE_NUMBERINGTYPE_HPP_ #ifndef _COM_SUN_STAR_STYLE_NUMBERINGTYPE_HPP_
#include <com/sun/star/style/NumberingType.hpp> #include <com/sun/star/style/NumberingType.hpp>
#endif #endif
...@@ -1408,7 +1409,10 @@ void DomainMapper::attribute(doctok::Id nName, doctok::Value & val) ...@@ -1408,7 +1409,10 @@ void DomainMapper::attribute(doctok::Id nName, doctok::Value & val)
break; break;
case NS_rtf::LN_BOOKMARKNAME: case NS_rtf::LN_BOOKMARKNAME:
/* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */
break; // sStringValue contains the bookmark name
// if it is already known then it's time to insert the bookmark
m_pImpl->AddBookmark( sStringValue );
break;
case NS_rtf::LN_LISTLEVEL: case NS_rtf::LN_LISTLEVEL:
/* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */ /* WRITERFILTERSTATUS: done: 0, planned: 0.5, spent: 0 */
...@@ -1544,10 +1548,14 @@ void DomainMapper::attribute(doctok::Id nName, doctok::Value & val) ...@@ -1544,10 +1548,14 @@ void DomainMapper::attribute(doctok::Id nName, doctok::Value & val)
//ignored //ignored
break; break;
case NS_rtf::LN_FONT: //font of footnote symbol case NS_rtf::LN_FONT: //font of footnote symbol
m_pImpl->SetFootnoteFontId( nIntValue ); m_pImpl->GetTopContext()->SetFootnoteFontId( nIntValue );
break; break;
case NS_ooxml::LN_CT_Sym_char:
case NS_rtf::LN_CHAR: //footnote symbol character case NS_rtf::LN_CHAR: //footnote symbol character
m_pImpl->SetFootnoteSymbol( sal_Unicode(nIntValue)); m_pImpl->GetTopContext()->SetFootnoteSymbol( sal_Unicode(nIntValue));
break;
case NS_ooxml::LN_CT_Sym_font:
m_pImpl->GetTopContext()->SetFootnoteFontName( sStringValue );
break; break;
case NS_ooxml::LN_CT_Underline_val: case NS_ooxml::LN_CT_Underline_val:
handleUnderlineType(nIntValue, m_pImpl->GetTopContext()); handleUnderlineType(nIntValue, m_pImpl->GetTopContext());
...@@ -3367,18 +3375,21 @@ void DomainMapper::text(const sal_uInt8 * data_, size_t len) ...@@ -3367,18 +3375,21 @@ void DomainMapper::text(const sal_uInt8 * data_, size_t len)
} }
if(bContinue) if(bContinue)
{ {
if( m_pImpl->IsOpenFieldCommand() ) PropertyMapPtr pContext = m_pImpl->GetTopContext();
if( pContext->GetFootnote().is() )
{
if( !pContext->GetFootnoteSymbol() )
pContext->GetFootnote()->setLabel( sText );
//otherwise ignore sText
}
else if( m_pImpl->IsOpenFieldCommand() )
m_pImpl->AppendFieldCommand(sText); m_pImpl->AppendFieldCommand(sText);
// if( m_pImpl->IsFieldMode())
// m_pImpl->CreateField( sText );
else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString()) else if( m_pImpl->IsOpenField() && m_pImpl->IsFieldResultAsString())
// else if( m_pImpl->IsFieldAvailable())
/*depending on the success of the field insert operation this result will be /*depending on the success of the field insert operation this result will be
set at the field or directly inserted into the text*/ set at the field or directly inserted into the text*/
m_pImpl->SetFieldResult( sText ); m_pImpl->SetFieldResult( sText );
else else
{ {
PropertyMapPtr pContext = m_pImpl->GetTopContext();
//--> debug //--> debug
//sal_uInt32 nSize = pContext->size(); //sal_uInt32 nSize = pContext->size();
//<-- //<--
...@@ -3409,11 +3420,21 @@ void DomainMapper::utext(const sal_uInt8 * data_, size_t len) ...@@ -3409,11 +3420,21 @@ void DomainMapper::utext(const sal_uInt8 * data_, size_t len)
m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH)); m_pImpl->finishParagraph(m_pImpl->GetTopContextOfType(CONTEXT_PARAGRAPH));
else else
{ {
PropertyMapPtr pContext = m_pImpl->GetTopContext(); PropertyMapPtr pContext = m_pImpl->GetTopContext();
//--> debug
//sal_uInt32 nSize = pContext->size(); //-->debug
//<-- uno::Reference<text::XFootnote> xTest = pContext->GetFootnote();
m_pImpl->appendTextPortion( sText, pContext ); //<--debug
if( xTest.is() )
// if( pContext->GetFootnote().is() )
{
if( !pContext->GetFootnoteSymbol() )
pContext->GetFootnote()->setLabel( sText );
//otherwise ignore sText
}
else
m_pImpl->appendTextPortion( sText, pContext );
} }
} }
catch( const uno::RuntimeException& ) catch( const uno::RuntimeException& )
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: DomainMapper_Impl.cxx,v $ * $RCSfile: DomainMapper_Impl.cxx,v $
* *
* $Revision: 1.16 $ * $Revision: 1.17 $
* *
* last change: $Author: os $ $Date: 2007-06-06 06:33:22 $ * last change: $Author: os $ $Date: 2007-06-12 05:40:45 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include <com/sun/star/uno/XComponentContext.hpp> #include <com/sun/star/uno/XComponentContext.hpp>
#include <com/sun/star/beans/XPropertySet.hpp> #include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/container/XIndexReplace.hpp> #include <com/sun/star/container/XIndexReplace.hpp>
#include <com/sun/star/container/XNamed.hpp>
#include <com/sun/star/document/XDocumentInfoSupplier.hpp> #include <com/sun/star/document/XDocumentInfoSupplier.hpp>
#include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp>
#include <com/sun/star/style/XStyleFamiliesSupplier.hpp> #include <com/sun/star/style/XStyleFamiliesSupplier.hpp>
...@@ -361,9 +362,7 @@ DomainMapper_Impl::DomainMapper_Impl( ...@@ -361,9 +362,7 @@ DomainMapper_Impl::DomainMapper_Impl(
m_nCurrentTabStopIndex( 0 ), m_nCurrentTabStopIndex( 0 ),
m_sCurrentParaStyleId(), m_sCurrentParaStyleId(),
m_bInStyleSheetImport( false ), m_bInStyleSheetImport( false ),
m_bLineNumberingSet( false ), m_bLineNumberingSet( false )
m_cFootnoteSymbol( 0 ),
m_nFootnoteFontId( -1 )
{ {
GetBodyText(); GetBodyText();
uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert = uno::Reference< text::XTextAppendAndConvert >( m_xBodyText, uno::UNO_QUERY ); uno::Reference< text::XTextAppendAndConvert > xBodyTextAppendAndConvert = uno::Reference< text::XTextAppendAndConvert >( m_xBodyText, uno::UNO_QUERY );
...@@ -875,35 +874,41 @@ void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote ) ...@@ -875,35 +874,41 @@ void DomainMapper_Impl::PushFootOrEndnote( bool bIsFootnote )
{ {
try try
{ {
PropertyMapPtr pTopContext = GetTopContext();
uno::Reference< text::XText > xFootnoteText( GetTextFactory()->createInstance( uno::Reference< text::XText > xFootnoteText( GetTextFactory()->createInstance(
bIsFootnote ? bIsFootnote ?
::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Footnote") ) : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote") )), ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Footnote") ) : ::rtl::OUString( RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Endnote") )),
uno::UNO_QUERY_THROW ); uno::UNO_QUERY_THROW );
if( m_cFootnoteSymbol != 0) uno::Reference< text::XFootnote > xFootnote( xFootnoteText, uno::UNO_QUERY_THROW );
pTopContext->SetFootnote( xFootnote );
if( pTopContext->GetFootnoteSymbol() != 0)
{ {
uno::Reference< text::XFootnote > xFootnote( xFootnoteText, uno::UNO_QUERY_THROW ); xFootnote->setLabel( ::rtl::OUString( pTopContext->GetFootnoteSymbol() ) );
xFootnote->setLabel( ::rtl::OUString( m_cFootnoteSymbol ) );
} }
FontTablePtr pFontTable = GetFontTable(); FontTablePtr pFontTable = GetFontTable();
uno::Sequence< beans::PropertyValue > aFontProperties; uno::Sequence< beans::PropertyValue > aFontProperties;
if( pFontTable && m_nFootnoteFontId >= 0 && pFontTable->size() > (size_t)m_nFootnoteFontId ) if( pFontTable && pTopContext->GetFootnoteFontId() >= 0 && pFontTable->size() > (size_t)pTopContext->GetFootnoteFontId() )
{ {
const FontEntry* pFontEntry = pFontTable->getFontEntry(sal_uInt32(m_nFootnoteFontId)); const FontEntry* pFontEntry = pFontTable->getFontEntry(sal_uInt32(pTopContext->GetFootnoteFontId()));
PropertyMapPtr aFontProps( new PropertyMap ); PropertyMapPtr aFontProps( new PropertyMap );
aFontProps->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( pFontEntry->sFontName )); aFontProps->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( pFontEntry->sFontName ));
aFontProps->Insert(PROP_CHAR_FONT_CHAR_SET, uno::makeAny( (sal_Int16)pFontEntry->nTextEncoding )); aFontProps->Insert(PROP_CHAR_FONT_CHAR_SET, uno::makeAny( (sal_Int16)pFontEntry->nTextEncoding ));
aFontProps->Insert(PROP_CHAR_FONT_PITCH, uno::makeAny( pFontEntry->nPitchRequest )); aFontProps->Insert(PROP_CHAR_FONT_PITCH, uno::makeAny( pFontEntry->nPitchRequest ));
aFontProperties = aFontProps->GetPropertyValues(); aFontProperties = aFontProps->GetPropertyValues();
} }
else if(pTopContext->GetFootnoteFontName().getLength())
{
PropertyMapPtr aFontProps( new PropertyMap );
aFontProps->Insert(PROP_CHAR_FONT_NAME, uno::makeAny( pTopContext->GetFootnoteFontName() ));
aFontProperties = aFontProps->GetPropertyValues();
}
appendTextContent( uno::Reference< text::XTextContent >( xFootnoteText, uno::UNO_QUERY_THROW ), aFontProperties ); appendTextContent( uno::Reference< text::XTextContent >( xFootnoteText, uno::UNO_QUERY_THROW ), aFontProperties );
m_aTextAppendStack.push(uno::Reference< text::XTextAppendAndConvert >( xFootnoteText, uno::UNO_QUERY_THROW )); m_aTextAppendStack.push(uno::Reference< text::XTextAppendAndConvert >( xFootnoteText, uno::UNO_QUERY_THROW ));
} }
catch( uno::Exception& ) catch( uno::Exception& )
{ {
} }
//reset footnote properties
m_nFootnoteFontId = -1;
m_cFootnoteSymbol = 0;
} }
/*-- 24.05.2007 14:22:29--------------------------------------------------- /*-- 24.05.2007 14:22:29---------------------------------------------------
...@@ -2730,23 +2735,51 @@ void DomainMapper_Impl::PopFieldContext() ...@@ -2730,23 +2735,51 @@ void DomainMapper_Impl::PopFieldContext()
//remove the field context //remove the field context
m_aFieldStack.pop(); m_aFieldStack.pop();
} }
/*-- 18.09.2006 15:47:09--------------------------------------------------- /*-- 11.06.2007 16:19:00---------------------------------------------------
the string _can_ be quoted or not be available at all
-----------------------------------------------------------------------*/ -----------------------------------------------------------------------*/
//void DomainMapper_Impl::ExtractAndSetDocumentInfo( void DomainMapper_Impl::AddBookmark( const ::rtl::OUString& rBookmarkName )
// const ::rtl::OUString& rCommand, sal_Int32 nCommandLength, PropertyIds ePropId ) {
//{ uno::Reference< text::XTextAppendAndConvert > xTextAppendAndConvert = m_aTextAppendStack.top();
// ::rtl::OUString sParam = lcl_ExtractParameter( rCommand, nCommandLength ); BookmarkMap_t::iterator aBookmarkIter = m_aBookmarkMap.find( rBookmarkName );
// if( sParam.getLength() ) //is the bookmark name already registered?
// { try
// uno::Reference< document::XDocumentInfoSupplier > xInfoSupplier( m_xTextDocument, uno::UNO_QUERY_THROW ); {
// uno::Reference< beans::XPropertySet > xInfoPropSet( xInfoSupplier->getDocumentInfo(), uno::UNO_QUERY_THROW ); if( aBookmarkIter != m_aBookmarkMap.end() )
// xInfoPropSet->setPropertyValue( {
// PropertyNameSupplier::GetPropertyNameSupplier().GetName(ePropId), uno::makeAny( sParam )); static const rtl::OUString sBookmarkService(RTL_CONSTASCII_USTRINGPARAM("com.sun.star.text.Bookmark"));
// } uno::Reference< text::XTextContent > xBookmark( m_xTextFactory->createInstance( sBookmarkService ), uno::UNO_QUERY_THROW );
uno::Reference< text::XTextCursor > xCursor;
//} uno::Reference< text::XText > xText = aBookmarkIter->second.m_xTextRange->getText();
if( aBookmarkIter->second.m_bIsStartOfText )
xCursor = xText->createTextCursorByRange( xText->getStart() );
else
{
xCursor = xText->createTextCursorByRange( aBookmarkIter->second.m_xTextRange );
xCursor->goRight( 1, false );
}
xCursor->gotoRange( xTextAppendAndConvert->getEnd(), true );
uno::Reference< container::XNamed > xBkmNamed( xBookmark, uno::UNO_QUERY_THROW );
//todo: make sure the name is not used already!
xBkmNamed->setName( rBookmarkName );
xTextAppendAndConvert->insertTextContent( uno::Reference< text::XTextRange >( xCursor, uno::UNO_QUERY_THROW), xBookmark, !xCursor->isCollapsed() );
m_aBookmarkMap.erase( aBookmarkIter );
}
else
{
//otherwise insert a text range as marker
uno::Reference< text::XTextCursor > xCursor = xTextAppendAndConvert->createTextCursorByRange( xTextAppendAndConvert->getEnd() );
bool bIsStart = !xCursor->goLeft(1, false);
uno::Reference< text::XTextRange > xCurrent = xCursor->getStart();
m_aBookmarkMap.insert(BookmarkMap_t::value_type( rBookmarkName, BookmarkInsertPosition( bIsStart, xCurrent ) ));
}
}
catch( const uno::Exception& )
{
//TODO: What happens to bookmarks where start and end are at different XText objects?
}
}
/*-- 01.11.2006 14:57:44--------------------------------------------------- /*-- 01.11.2006 14:57:44---------------------------------------------------
-----------------------------------------------------------------------*/ -----------------------------------------------------------------------*/
......
...@@ -4,9 +4,9 @@ ...@@ -4,9 +4,9 @@
* *
* $RCSfile: DomainMapper_Impl.hxx,v $ * $RCSfile: DomainMapper_Impl.hxx,v $
* *
* $Revision: 1.15 $ * $Revision: 1.16 $
* *
* last change: $Author: os $ $Date: 2007-06-06 06:33:22 $ * last change: $Author: os $ $Date: 2007-06-12 05:40:46 $
* *
* The Contents of this file are made available subject to * The Contents of this file are made available subject to
* the terms of GNU Lesser General Public License Version 2.1. * the terms of GNU Lesser General Public License Version 2.1.
...@@ -72,13 +72,17 @@ ...@@ -72,13 +72,17 @@
#ifndef INCLUDED_GRAPHICIMPORT_HXX #ifndef INCLUDED_GRAPHICIMPORT_HXX
#include <GraphicImport.hxx> #include <GraphicImport.hxx>
#endif #endif
#include <map>
namespace com{ namespace sun{ namespace star{ namespace com{ namespace sun{ namespace star{
namespace lang{ namespace lang{
class XMultiServiceFactory; class XMultiServiceFactory;
struct Locale; struct Locale;
} }
namespace text{ class XTextField;} namespace text
{
class XTextField;
}
namespace beans{ class XPropertySet;} namespace beans{ class XPropertySet;}
}}} }}}
...@@ -182,6 +186,18 @@ struct DeletableTabStop : public ::com::sun::star::style::TabStop ...@@ -182,6 +186,18 @@ struct DeletableTabStop : public ::com::sun::star::style::TabStop
TabStop( rTabStop ), TabStop( rTabStop ),
bDeleted( false ){} bDeleted( false ){}
}; };
/*-- 12.06.2007 07:15:31---------------------------------------------------
/// helper to remember bookmark start position
-----------------------------------------------------------------------*/
struct BookmarkInsertPosition
{
bool m_bIsStartOfText;
::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > m_xTextRange;
BookmarkInsertPosition(bool bIsStartOfText, ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange > xTextRange):
m_bIsStartOfText( bIsStartOfText ),
m_xTextRange( xTextRange )
{}
};
/*-- 09.06.2006 10:15:20--------------------------------------------------- /*-- 09.06.2006 10:15:20---------------------------------------------------
-----------------------------------------------------------------------*/ -----------------------------------------------------------------------*/
...@@ -191,6 +207,7 @@ class DomainMapper_Impl ...@@ -191,6 +207,7 @@ class DomainMapper_Impl
public: public:
typedef doctok::TableManager< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, PropertyMapPtr > TableManager_t; typedef doctok::TableManager< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, PropertyMapPtr > TableManager_t;
typedef doctok::TableDataHandler< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, PropertyMapPtr > TableDataHandler_t; typedef doctok::TableDataHandler< ::com::sun::star::uno::Reference< ::com::sun::star::text::XTextRange >, PropertyMapPtr > TableDataHandler_t;
typedef std::map < ::rtl::OUString, BookmarkInsertPosition > BookmarkMap_t;
private: private:
DomainMapper& m_rDMapper; DomainMapper& m_rDMapper;
...@@ -208,6 +225,8 @@ private: ...@@ -208,6 +225,8 @@ private:
bool m_bSetUserFieldContent; bool m_bSetUserFieldContent;
bool m_bIsFirstSection; bool m_bIsFirstSection;
BookmarkMap_t m_aBookmarkMap;
DomainMapperTableManager m_TableManager; DomainMapperTableManager m_TableManager;
//each context needs a stack of currently used attributes //each context needs a stack of currently used attributes
...@@ -228,9 +247,6 @@ private: ...@@ -228,9 +247,6 @@ private:
bool m_bInStyleSheetImport; bool m_bInStyleSheetImport;
bool m_bLineNumberingSet; bool m_bLineNumberingSet;
// bool m_bIsFootnoteSymbol;
sal_Unicode m_cFootnoteSymbol; // 0 == invalid
sal_Int32 m_nFootnoteFontId; // negative values are invalid ids
void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale); void GetCurrentLocale(::com::sun::star::lang::Locale& rLocale);
void SetNumberFormat( const ::rtl::OUString& rCommand, void SetNumberFormat( const ::rtl::OUString& rCommand,
...@@ -344,28 +360,13 @@ public: ...@@ -344,28 +360,13 @@ public:
//the end of field is reached (0x15 appeared) - the command might still be open //the end of field is reached (0x15 appeared) - the command might still be open
void PopFieldContext(); void PopFieldContext();
//create a new field from the command string void AddBookmark( const ::rtl::OUString& rBookmarkName );
// void CreateField( ::rtl::OUString& rCommand );
//set the field result in insert the field
// void SetFieldMode( bool bSet ) { m_bFieldMode = bSet; }
// bool IsFieldMode() const { return m_bFieldMode; }
// void SetFieldResult( ::rtl::OUString& rResult );
// bool IsFieldAvailable() const;
TableManager_t & getTableManager() { return m_TableManager; } TableManager_t & getTableManager() { return m_TableManager; }
void SetLineNumbering( sal_Int32 nLnnMod, sal_Int32 nLnc, sal_Int32 ndxaLnn ); void SetLineNumbering( sal_Int32 nLnnMod, sal_Int32 nLnc, sal_Int32 ndxaLnn );
bool IsLineNumberingSet() const {return m_bLineNumberingSet;} bool IsLineNumberingSet() const {return m_bLineNumberingSet;}
// bool IsFootnoteSymbol() const { return m_bIsFootnoteSymbol;}
// void SetFootnoteSymbol() { m_bIsFootnoteSymbol = true;}
// void ResetFootnoteSymbol() { m_bIsFootnoteSymbol = false;}
sal_Unicode GetFootnoteSymbol() const { return m_cFootnoteSymbol;}
void SetFootnoteSymbol(sal_Unicode cSet) { m_cFootnoteSymbol = cSet;}
sal_Int32 GetFootnoteFontId() const { return m_nFootnoteFontId;}
void SetFootnoteFontId(sal_Int32 nSet) { m_nFootnoteFontId = nSet;}
DeletableTabStop m_aCurrentTabStop; DeletableTabStop m_aCurrentTabStop;
}; };
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment