merge the formfield patch from ooo-build
[ooovba.git] / oox / source / xls / richstringcontext.cxx
blobc64c52c2598bb32805598e70b219371919c2807f
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 $
10 * $Revision: 1.4 $
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;
37 namespace oox {
38 namespace xls {
40 // ============================================================================
42 // oox.core.ContextHandler2Helper interface -----------------------------------
44 ContextHandlerRef OoxRichStringContext::onCreateContext( sal_Int32 nElement, const AttributeList& rAttribs )
46 if( isRootElement() )
48 switch( nElement )
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() )
58 case XLS_TOKEN( r ):
59 switch( nElement )
61 case XLS_TOKEN( rPr ):
62 if( mxPortion.get() )
63 return new OoxFontContext( *this, mxPortion->createFont() );
64 break;
66 case XLS_TOKEN( t ):
67 return this; // collect portion text in onEndElement()
69 break;
71 case XLS_TOKEN( rPh ):
72 switch( nElement )
74 case XLS_TOKEN( t ):
75 return this; // collect phonetic text in onEndElement()
77 break;
79 return 0;
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 // ============================================================================
96 } // namespace xls
97 } // namespace oox