1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: richstringcontext.cxx,v $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #include "oox/xls/richstringcontext.hxx"
32 #include "oox/xls/stylesfragment.hxx"
34 using ::rtl::OUString
;
35 using ::oox::core::ContextHandlerRef
;
40 // ============================================================================
42 // oox.core.ContextHandler2Helper interface -----------------------------------
44 ContextHandlerRef
OoxRichStringContext::onCreateContext( sal_Int32 nElement
, const AttributeList
& rAttribs
)
50 case XLS_TOKEN( t
): mxPortion
= mxString
->importText( rAttribs
); return this; // collect text in onEndElement()
51 case XLS_TOKEN( r
): mxPortion
= mxString
->importRun( rAttribs
); return this;
52 case XLS_TOKEN( rPh
): mxPhonetic
= mxString
->importPhoneticRun( rAttribs
); return this;
53 case XLS_TOKEN( phoneticPr
): mxString
->importPhoneticPr( rAttribs
); break;
56 else switch( getCurrentElement() )
61 case XLS_TOKEN( rPr
):
63 return new OoxFontContext( *this, mxPortion
->createFont() );
67 return this; // collect portion text in onEndElement()
71 case XLS_TOKEN( rPh
):
75 return this; // collect phonetic text in onEndElement()
82 void OoxRichStringContext::onEndElement( const OUString
& rChars
)
84 if( getCurrentElement() == XLS_TOKEN( t
) )
86 switch( getPreviousElement() )
88 case XLS_TOKEN( rPh
): if( mxPhonetic
.get() ) mxPhonetic
->setText( rChars
); break;
89 default: if( mxPortion
.get() ) mxPortion
->setText( rChars
); break;
94 // ============================================================================