163bba73cSAndrew Rist /**************************************************************
2cdf0e10cSrcweir *
363bba73cSAndrew Rist * Licensed to the Apache Software Foundation (ASF) under one
463bba73cSAndrew Rist * or more contributor license agreements. See the NOTICE file
563bba73cSAndrew Rist * distributed with this work for additional information
663bba73cSAndrew Rist * regarding copyright ownership. The ASF licenses this file
763bba73cSAndrew Rist * to you under the Apache License, Version 2.0 (the
863bba73cSAndrew Rist * "License"); you may not use this file except in compliance
963bba73cSAndrew Rist * with the License. You may obtain a copy of the License at
10cdf0e10cSrcweir *
1163bba73cSAndrew Rist * http://www.apache.org/licenses/LICENSE-2.0
12cdf0e10cSrcweir *
1363bba73cSAndrew Rist * Unless required by applicable law or agreed to in writing,
1463bba73cSAndrew Rist * software distributed under the License is distributed on an
1563bba73cSAndrew Rist * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
1663bba73cSAndrew Rist * KIND, either express or implied. See the License for the
1763bba73cSAndrew Rist * specific language governing permissions and limitations
1863bba73cSAndrew Rist * under the License.
19cdf0e10cSrcweir *
2063bba73cSAndrew Rist *************************************************************/
2163bba73cSAndrew Rist
2263bba73cSAndrew Rist
23cdf0e10cSrcweir
24cdf0e10cSrcweir // MARKER(update_precomp.py): autogen include statement, do not remove
25cdf0e10cSrcweir #include "precompiled_xmloff.hxx"
26cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXParseException.hpp>
27cdf0e10cSrcweir #include <com/sun/star/xml/sax/SAXException.hpp>
28cdf0e10cSrcweir #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
29cdf0e10cSrcweir #include <com/sun/star/xml/sax/XAttributeList.hpp>
30cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
31cdf0e10cSrcweir #include <xmloff/nmspmap.hxx>
32cdf0e10cSrcweir #include <xmloff/xmltoken.hxx>
33cdf0e10cSrcweir #include "xmloff/xmlnmspe.hxx"
34cdf0e10cSrcweir #include "PropType.hxx"
35cdf0e10cSrcweir #include "DeepTContext.hxx"
36cdf0e10cSrcweir #include "ProcAttrTContext.hxx"
37cdf0e10cSrcweir #ifndef _XMLOFF_TRANSFOERMERBASE_HXX
38cdf0e10cSrcweir #include "TransformerBase.hxx"
39cdf0e10cSrcweir #endif
40cdf0e10cSrcweir #include "TransformerActions.hxx"
41cdf0e10cSrcweir #include "ActionMapTypesOASIS.hxx"
42cdf0e10cSrcweir #include "MutableAttrList.hxx"
43cdf0e10cSrcweir #include "PropertyActionsOASIS.hxx"
44cdf0e10cSrcweir #include "StyleOASISTContext.hxx"
45cdf0e10cSrcweir #include <xmloff/xmluconv.hxx>
46cdf0e10cSrcweir #include <rtl/ustrbuf.hxx>
47cdf0e10cSrcweir
48cdf0e10cSrcweir using ::rtl::OUString;
49cdf0e10cSrcweir using namespace ::xmloff::token;
50cdf0e10cSrcweir using namespace ::com::sun::star::uno;
51cdf0e10cSrcweir using namespace ::com::sun::star::xml::sax;
52cdf0e10cSrcweir //------------------------------------------------------------------------------
53cdf0e10cSrcweir
54cdf0e10cSrcweir static sal_uInt16 aAttrActionMaps[XML_PROP_TYPE_END] =
55cdf0e10cSrcweir {
56cdf0e10cSrcweir PROP_OASIS_GRAPHIC_ATTR_ACTIONS,
57cdf0e10cSrcweir PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS, // DRAWING_PAGE
58cdf0e10cSrcweir PROP_OASIS_PAGE_LAYOUT_ATTR_ACTIONS,
59cdf0e10cSrcweir PROP_OASIS_HEADER_FOOTER_ATTR_ACTIONS,
60cdf0e10cSrcweir PROP_OASIS_TEXT_ATTR_ACTIONS,
61cdf0e10cSrcweir PROP_OASIS_PARAGRAPH_ATTR_ACTIONS,
62cdf0e10cSrcweir MAX_OASIS_PROP_ACTIONS, // RUBY
63cdf0e10cSrcweir PROP_OASIS_SECTION_ATTR_ACTIONS,
64cdf0e10cSrcweir PROP_OASIS_TABLE_ATTR_ACTIONS,
65cdf0e10cSrcweir PROP_OASIS_TABLE_COLUMN_ATTR_ACTIONS,
66cdf0e10cSrcweir PROP_OASIS_TABLE_ROW_ATTR_ACTIONS,
67cdf0e10cSrcweir PROP_OASIS_TABLE_CELL_ATTR_ACTIONS,
68cdf0e10cSrcweir PROP_OASIS_LIST_LEVEL_ATTR_ACTIONS,
69cdf0e10cSrcweir PROP_OASIS_CHART_ATTR_ACTIONS
70cdf0e10cSrcweir };
71cdf0e10cSrcweir
72cdf0e10cSrcweir //------------------------------------------------------------------------------
73cdf0e10cSrcweir
74cdf0e10cSrcweir class XMLPropertiesTContext_Impl : public XMLPersElemContentTContext
75cdf0e10cSrcweir {
76cdf0e10cSrcweir ::com::sun::star::uno::Reference<
77cdf0e10cSrcweir ::com::sun::star::xml::sax::XAttributeList > m_xAttrList;
78cdf0e10cSrcweir
79cdf0e10cSrcweir XMLPropType m_ePropType;
80cdf0e10cSrcweir sal_Bool m_bControlStyle;
81cdf0e10cSrcweir ::rtl::OUString m_aStyleFamily;
82cdf0e10cSrcweir
83cdf0e10cSrcweir public:
84cdf0e10cSrcweir
SetQNameAndPropType(const::rtl::OUString & rQName,XMLPropType ePropType)85cdf0e10cSrcweir void SetQNameAndPropType( const ::rtl::OUString& rQName,
86cdf0e10cSrcweir XMLPropType ePropType )
87cdf0e10cSrcweir {
88cdf0e10cSrcweir m_ePropType = ePropType;
89cdf0e10cSrcweir XMLTransformerContext::SetQName( rQName );
90cdf0e10cSrcweir };
91cdf0e10cSrcweir
92cdf0e10cSrcweir TYPEINFO();
93cdf0e10cSrcweir
94cdf0e10cSrcweir XMLPropertiesTContext_Impl( XMLTransformerBase& rTransformer,
95cdf0e10cSrcweir const ::rtl::OUString& rQName,
96cdf0e10cSrcweir XMLPropType eP,
97cdf0e10cSrcweir const ::rtl::OUString& rStyleFamily,
98cdf0e10cSrcweir sal_Bool _bControlStyle = sal_False );
99cdf0e10cSrcweir
100cdf0e10cSrcweir virtual ~XMLPropertiesTContext_Impl();
101cdf0e10cSrcweir
102cdf0e10cSrcweir virtual void StartElement( const ::com::sun::star::uno::Reference< ::com::sun::star::xml::sax::XAttributeList >& xAttrList );
103cdf0e10cSrcweir
104cdf0e10cSrcweir virtual void Export();
105cdf0e10cSrcweir
106cdf0e10cSrcweir static XMLPropType GetPropType( const OUString& rLocalName );
107cdf0e10cSrcweir
108cdf0e10cSrcweir static OUString MergeUnderline( XMLTokenEnum eUnderline,
109cdf0e10cSrcweir sal_Bool bBold, sal_Bool bDouble );
110cdf0e10cSrcweir static OUString MergeLineThrough( XMLTokenEnum eLineThrough,
111cdf0e10cSrcweir sal_Bool bBold, sal_Bool bDouble,
112cdf0e10cSrcweir sal_Unicode c );
113cdf0e10cSrcweir };
114cdf0e10cSrcweir
115cdf0e10cSrcweir TYPEINIT1( XMLPropertiesTContext_Impl, XMLPersElemContentTContext );
116cdf0e10cSrcweir
XMLPropertiesTContext_Impl(XMLTransformerBase & rImp,const OUString & rQName,XMLPropType eP,const::rtl::OUString & rStyleFamily,sal_Bool _bControlStyle)117cdf0e10cSrcweir XMLPropertiesTContext_Impl::XMLPropertiesTContext_Impl(
118cdf0e10cSrcweir XMLTransformerBase& rImp, const OUString& rQName, XMLPropType eP,
119cdf0e10cSrcweir const ::rtl::OUString& rStyleFamily, sal_Bool _bControlStyle ) :
120cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName, XML_NAMESPACE_STYLE,
121cdf0e10cSrcweir XML_PROPERTIES),
122cdf0e10cSrcweir m_ePropType( eP ),
123cdf0e10cSrcweir m_bControlStyle( _bControlStyle ),
124cdf0e10cSrcweir m_aStyleFamily( rStyleFamily )
125cdf0e10cSrcweir {
126cdf0e10cSrcweir }
127cdf0e10cSrcweir
~XMLPropertiesTContext_Impl()128cdf0e10cSrcweir XMLPropertiesTContext_Impl::~XMLPropertiesTContext_Impl()
129cdf0e10cSrcweir {
130cdf0e10cSrcweir }
131cdf0e10cSrcweir
StartElement(const Reference<XAttributeList> & rAttrList)132cdf0e10cSrcweir void XMLPropertiesTContext_Impl::StartElement(
133cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList )
134cdf0e10cSrcweir {
135cdf0e10cSrcweir XMLTransformerActions *pActions = 0;
136cdf0e10cSrcweir sal_uInt16 nActionMap = aAttrActionMaps[m_ePropType];
137cdf0e10cSrcweir if( nActionMap < MAX_OASIS_PROP_ACTIONS )
138cdf0e10cSrcweir {
139cdf0e10cSrcweir pActions = GetTransformer().GetUserDefinedActions( nActionMap );
140cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" );
141cdf0e10cSrcweir }
142cdf0e10cSrcweir
143cdf0e10cSrcweir if( pActions )
144cdf0e10cSrcweir {
145cdf0e10cSrcweir XMLMutableAttributeList *pAttrList = 0;
146cdf0e10cSrcweir if( !m_xAttrList.is() )
147cdf0e10cSrcweir {
148cdf0e10cSrcweir pAttrList = new XMLMutableAttributeList();
149cdf0e10cSrcweir m_xAttrList = pAttrList;
150cdf0e10cSrcweir }
151cdf0e10cSrcweir else
152cdf0e10cSrcweir {
153cdf0e10cSrcweir pAttrList =
154cdf0e10cSrcweir static_cast< XMLMutableAttributeList * >( m_xAttrList.get() );
155cdf0e10cSrcweir }
156cdf0e10cSrcweir
157cdf0e10cSrcweir XMLTokenEnum eUnderline = XML_TOKEN_END;
158cdf0e10cSrcweir sal_Bool bBoldUnderline = sal_False, bDoubleUnderline = sal_False;
159cdf0e10cSrcweir XMLTokenEnum eLineThrough = XML_TOKEN_END;
160cdf0e10cSrcweir sal_Bool bBoldLineThrough = sal_False, bDoubleLineThrough = sal_False;
161cdf0e10cSrcweir sal_Unicode cLineThroughChar = 0;
162cdf0e10cSrcweir
163cdf0e10cSrcweir bool bIntervalMinorFound = false;
164cdf0e10cSrcweir double fIntervalMajor = 0.0;
165cdf0e10cSrcweir sal_Int32 nIntervalMinorDivisor = 0;
166cdf0e10cSrcweir
167cdf0e10cSrcweir // #i25616#
168cdf0e10cSrcweir OUString aOpacityValueRemember;
169cdf0e10cSrcweir OUString aImageOpacityValueRemember;
170cdf0e10cSrcweir
171cdf0e10cSrcweir sal_Int16 nAttrCount = rAttrList.is() ? rAttrList->getLength() : 0;
172cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ )
173cdf0e10cSrcweir {
174cdf0e10cSrcweir const OUString& rAttrName = rAttrList->getNameByIndex( i );
175cdf0e10cSrcweir const OUString& rAttrValue = rAttrList->getValueByIndex( i );
176cdf0e10cSrcweir OUString aLocalName;
177cdf0e10cSrcweir sal_uInt16 nPrefix =
178cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
179cdf0e10cSrcweir &aLocalName );
180cdf0e10cSrcweir
181cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
182cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter =
183cdf0e10cSrcweir pActions->find( aKey );
184cdf0e10cSrcweir if( !(aIter == pActions->end() ) )
185cdf0e10cSrcweir {
186cdf0e10cSrcweir switch( (*aIter).second.m_nActionType )
187cdf0e10cSrcweir {
188cdf0e10cSrcweir case XML_ATACTION_REMOVE:
189cdf0e10cSrcweir break;
190cdf0e10cSrcweir case XML_ATACTION_COPY:
191cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue );
192cdf0e10cSrcweir break;
193cdf0e10cSrcweir case XML_ATACTION_RENAME:
194cdf0e10cSrcweir {
195cdf0e10cSrcweir OUString aNewAttrQName(
196cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
197cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
198cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
199cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) );
200cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
201cdf0e10cSrcweir }
202cdf0e10cSrcweir break;
203cdf0e10cSrcweir case XML_ATACTION_IN2INCH:
204cdf0e10cSrcweir {
205cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
206cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInWithInch(
207cdf0e10cSrcweir aAttrValue );
208cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue );
209cdf0e10cSrcweir }
210cdf0e10cSrcweir break;
211cdf0e10cSrcweir case XML_ATACTION_INS2INCHS:
212cdf0e10cSrcweir {
213cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
214cdf0e10cSrcweir XMLTransformerBase::ReplaceInWithInch(
215cdf0e10cSrcweir aAttrValue );
216cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue );
217cdf0e10cSrcweir }
218cdf0e10cSrcweir break;
219cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME_REF:
220cdf0e10cSrcweir {
221cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
222cdf0e10cSrcweir GetTransformer().DecodeStyleName(aAttrValue);
223cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue );
224cdf0e10cSrcweir }
225cdf0e10cSrcweir break;
226cdf0e10cSrcweir case XML_ATACTION_RENAME_DECODE_STYLE_NAME_REF:
227cdf0e10cSrcweir {
228cdf0e10cSrcweir OUString aNewAttrQName(
229cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
230cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
231cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
232cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) );
233cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
234cdf0e10cSrcweir GetTransformer().DecodeStyleName(aAttrValue);
235cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, aAttrValue );
236cdf0e10cSrcweir }
237cdf0e10cSrcweir break;
238cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT:
239cdf0e10cSrcweir {
240cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
241cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue);
242cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue );
243cdf0e10cSrcweir }
244cdf0e10cSrcweir break;
245cdf0e10cSrcweir case XML_ATACTION_RENAME_NEG_PERCENT:
246cdf0e10cSrcweir {
247cdf0e10cSrcweir OUString aNewAttrQName(
248cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
249cdf0e10cSrcweir (*aIter).second.GetQNamePrefixFromParam1(),
250cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
251cdf0e10cSrcweir (*aIter).second.GetQNameTokenFromParam1()) ) );
252cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
253cdf0e10cSrcweir GetTransformer().NegPercent(aAttrValue);
254cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, aAttrValue );
255cdf0e10cSrcweir }
256cdf0e10cSrcweir break;
257cdf0e10cSrcweir case XML_OPTACTION_LINE_MODE:
258cdf0e10cSrcweir {
259cdf0e10cSrcweir sal_Bool bWordMode =
260cdf0e10cSrcweir IsXMLToken( rAttrValue, XML_SKIP_WHITE_SPACE );
261cdf0e10cSrcweir OUString aAttrQName(
262cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
263cdf0e10cSrcweir XML_NAMESPACE_FO,
264cdf0e10cSrcweir GetXMLToken( XML_SCORE_SPACES ) ) );
265cdf0e10cSrcweir sal_Int16 nIndex =
266cdf0e10cSrcweir pAttrList->GetIndexByName( aAttrQName );
267cdf0e10cSrcweir if( -1 != nIndex )
268cdf0e10cSrcweir {
269cdf0e10cSrcweir if( bWordMode )
270cdf0e10cSrcweir {
271cdf0e10cSrcweir const OUString& rOldValue =
272cdf0e10cSrcweir pAttrList->getValueByIndex( nIndex );
273cdf0e10cSrcweir if( !IsXMLToken( rOldValue, XML_TRUE ) )
274cdf0e10cSrcweir {
275cdf0e10cSrcweir pAttrList->SetValueByIndex( nIndex,
276cdf0e10cSrcweir GetXMLToken( XML_TRUE ) );
277cdf0e10cSrcweir }
278cdf0e10cSrcweir }
279cdf0e10cSrcweir }
280cdf0e10cSrcweir else
281cdf0e10cSrcweir {
282cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( bWordMode
283cdf0e10cSrcweir ? XML_FALSE
284cdf0e10cSrcweir : XML_TRUE ) );
285cdf0e10cSrcweir pAttrList->AddAttribute( aAttrQName, aAttrValue );
286cdf0e10cSrcweir }
287cdf0e10cSrcweir }
288cdf0e10cSrcweir break;
289cdf0e10cSrcweir case XML_OPTACTION_KEEP_WITH_NEXT:
290cdf0e10cSrcweir {
291cdf0e10cSrcweir OUString aAttrValue( GetXMLToken(
292cdf0e10cSrcweir IsXMLToken( rAttrValue, XML_ALWAYS )
293cdf0e10cSrcweir ? XML_TRUE
294cdf0e10cSrcweir : XML_FALSE) );
295cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue );
296cdf0e10cSrcweir }
297cdf0e10cSrcweir break;
298cdf0e10cSrcweir case XML_OPTACTION_UNDERLINE_WIDTH:
299cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_BOLD ) )
300cdf0e10cSrcweir bBoldUnderline = sal_True;
301cdf0e10cSrcweir break;
302cdf0e10cSrcweir case XML_OPTACTION_UNDERLINE_TYPE:
303cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_DOUBLE ) )
304cdf0e10cSrcweir bDoubleUnderline = sal_True;
305cdf0e10cSrcweir break;
306cdf0e10cSrcweir case XML_OPTACTION_UNDERLINE_STYLE:
307cdf0e10cSrcweir eUnderline = GetTransformer().GetToken( rAttrValue );
308cdf0e10cSrcweir break;
309cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_WIDTH:
310cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_BOLD ) )
311cdf0e10cSrcweir bBoldLineThrough = sal_True;
312cdf0e10cSrcweir break;
313cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_TYPE:
314cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_DOUBLE ) )
315cdf0e10cSrcweir bDoubleLineThrough = sal_True;
316cdf0e10cSrcweir break;
317cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_STYLE:
318cdf0e10cSrcweir eLineThrough = GetTransformer().GetToken( rAttrValue );
319cdf0e10cSrcweir break;
320cdf0e10cSrcweir case XML_OPTACTION_LINETHROUGH_TEXT:
321cdf0e10cSrcweir if( rAttrValue.getLength() )
322cdf0e10cSrcweir cLineThroughChar = rAttrValue[0];
323cdf0e10cSrcweir break;
324cdf0e10cSrcweir case XML_OPTACTION_INTERPOLATION:
325cdf0e10cSrcweir {
326cdf0e10cSrcweir // 0: none
327cdf0e10cSrcweir sal_Int32 nSplineType = 0;
328cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_CUBIC_SPLINE ))
329cdf0e10cSrcweir nSplineType = 1;
330cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_B_SPLINE ))
331cdf0e10cSrcweir nSplineType = 2;
332cdf0e10cSrcweir
333cdf0e10cSrcweir pAttrList->AddAttribute(
334cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
335cdf0e10cSrcweir XML_NAMESPACE_CHART,
336cdf0e10cSrcweir GetXMLToken( XML_SPLINES )),
337cdf0e10cSrcweir OUString::valueOf( nSplineType ));
338cdf0e10cSrcweir }
339cdf0e10cSrcweir break;
340cdf0e10cSrcweir case XML_OPTACTION_INTERVAL_MAJOR:
341cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue );
342cdf0e10cSrcweir SvXMLUnitConverter::convertDouble( fIntervalMajor, rAttrValue );
343cdf0e10cSrcweir break;
344cdf0e10cSrcweir case XML_OPTACTION_INTERVAL_MINOR_DIVISOR:
345cdf0e10cSrcweir SvXMLUnitConverter::convertNumber( nIntervalMinorDivisor, rAttrValue );
346cdf0e10cSrcweir bIntervalMinorFound = true;
347cdf0e10cSrcweir break;
348cdf0e10cSrcweir case XML_OPTACTION_SYMBOL_TYPE:
349cdf0e10cSrcweir {
350cdf0e10cSrcweir // if symbol_type is "named-symbol" the "symbol"
351cdf0e10cSrcweir // property is set in the action XML_OPTACTION_SYMBOL_NAME
352cdf0e10cSrcweir sal_Int32 nSymbolType = 0;
353cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_NONE ))
354cdf0e10cSrcweir nSymbolType = -3;
355cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_AUTOMATIC ))
356cdf0e10cSrcweir nSymbolType = -2;
357cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_IMAGE ))
358cdf0e10cSrcweir nSymbolType = -1;
359cdf0e10cSrcweir
360cdf0e10cSrcweir if( nSymbolType < 0 )
361cdf0e10cSrcweir pAttrList->AddAttribute(
362cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
363cdf0e10cSrcweir XML_NAMESPACE_CHART,
364cdf0e10cSrcweir GetXMLToken( XML_SYMBOL )),
365cdf0e10cSrcweir OUString::valueOf( nSymbolType ));
366cdf0e10cSrcweir }
367cdf0e10cSrcweir break;
368cdf0e10cSrcweir case XML_OPTACTION_SYMBOL_NAME:
369cdf0e10cSrcweir {
370cdf0e10cSrcweir // assume "symbol-type" == "named-symbol"
371cdf0e10cSrcweir sal_Int32 nSymbolType = -3; // NONE
372cdf0e10cSrcweir // "square" just has an awkward token-name
373cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_GRADIENTSTYLE_SQUARE ))
374cdf0e10cSrcweir nSymbolType = 0;
375cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_DIAMOND ))
376cdf0e10cSrcweir nSymbolType = 1;
377cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_DOWN ))
378cdf0e10cSrcweir nSymbolType = 2;
379cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_UP ))
380cdf0e10cSrcweir nSymbolType = 3;
381cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_RIGHT ))
382cdf0e10cSrcweir nSymbolType = 4;
383cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_ARROW_LEFT ))
384cdf0e10cSrcweir nSymbolType = 5;
385cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_BOW_TIE ))
386cdf0e10cSrcweir nSymbolType = 6;
387cdf0e10cSrcweir else if( IsXMLToken( rAttrValue, XML_HOURGLASS ))
388cdf0e10cSrcweir nSymbolType = 7;
389*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_CIRCLE ))
390*3a5971bbSRegina Henschel nSymbolType = 8;
391*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_STAR ))
392*3a5971bbSRegina Henschel nSymbolType = 9;
393*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_X ))
394*3a5971bbSRegina Henschel nSymbolType = 10;
395*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_PLUS ))
396*3a5971bbSRegina Henschel nSymbolType = 11;
397*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_ASTERISK ))
398*3a5971bbSRegina Henschel nSymbolType = 12;
399*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_HORIZONTAL_BAR ))
400*3a5971bbSRegina Henschel nSymbolType = 13;
401*3a5971bbSRegina Henschel else if( IsXMLToken( rAttrValue, XML_VERTICAL_BAR ))
402*3a5971bbSRegina Henschel nSymbolType = 14;
403cdf0e10cSrcweir
404cdf0e10cSrcweir if( nSymbolType >= 0 )
405cdf0e10cSrcweir pAttrList->AddAttribute(
406cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
407cdf0e10cSrcweir XML_NAMESPACE_CHART,
408cdf0e10cSrcweir GetXMLToken( XML_SYMBOL )),
409cdf0e10cSrcweir OUString::valueOf( nSymbolType ));
410cdf0e10cSrcweir }
411cdf0e10cSrcweir break;
412cdf0e10cSrcweir // #i25616#
413cdf0e10cSrcweir case XML_OPTACTION_OPACITY:
414cdf0e10cSrcweir aOpacityValueRemember = rAttrValue;
415cdf0e10cSrcweir GetTransformer().NegPercent(aOpacityValueRemember);
416cdf0e10cSrcweir break;
417cdf0e10cSrcweir
418cdf0e10cSrcweir // #i25616#
419cdf0e10cSrcweir case XML_OPTACTION_IMAGE_OPACITY:
420cdf0e10cSrcweir aImageOpacityValueRemember = rAttrValue;
421cdf0e10cSrcweir GetTransformer().NegPercent(aImageOpacityValueRemember);
422cdf0e10cSrcweir break;
423cdf0e10cSrcweir
424cdf0e10cSrcweir case XML_OPTACTION_KEEP_TOGETHER:
425cdf0e10cSrcweir pAttrList->AddAttribute(
426cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
427cdf0e10cSrcweir XML_NAMESPACE_STYLE,GetXMLToken(XML_BREAK_INSIDE)),
428cdf0e10cSrcweir GetXMLToken(
429cdf0e10cSrcweir IsXMLToken( rAttrValue, XML_ALWAYS )
430cdf0e10cSrcweir ? XML_COLUMNSPLIT_AVOID
431cdf0e10cSrcweir : XML_COLUMNSPLIT_AUTO ) );
432cdf0e10cSrcweir break;
433cdf0e10cSrcweir
434cdf0e10cSrcweir case XML_OPTACTION_CONTROL_TEXT_ALIGN:
435cdf0e10cSrcweir if ( m_bControlStyle )
436cdf0e10cSrcweir {
437cdf0e10cSrcweir OUString aNewAttrQName(
438cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
439cdf0e10cSrcweir XML_NAMESPACE_STYLE,
440cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
441cdf0e10cSrcweir XML_TEXT_ALIGN ) ) );
442cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
443cdf0e10cSrcweir }
444cdf0e10cSrcweir else
445cdf0e10cSrcweir {
446cdf0e10cSrcweir OUString aNewAttrQName(
447cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
448cdf0e10cSrcweir XML_NAMESPACE_FO,
449cdf0e10cSrcweir ::xmloff::token::GetXMLToken(
450cdf0e10cSrcweir XML_TEXT_ALIGN ) ) );
451cdf0e10cSrcweir pAttrList->AddAttribute( aNewAttrQName, rAttrValue );
452cdf0e10cSrcweir }
453cdf0e10cSrcweir break;
454cdf0e10cSrcweir
455cdf0e10cSrcweir case XML_OPTACTION_DRAW_WRITING_MODE:
456cdf0e10cSrcweir if( IsXMLToken( m_aStyleFamily, XML_GRAPHICS ) )
457cdf0e10cSrcweir {
458cdf0e10cSrcweir pAttrList->AddAttribute(
459cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
460cdf0e10cSrcweir XML_NAMESPACE_DRAW,
461cdf0e10cSrcweir GetXMLToken( XML_WRITING_MODE ) ), rAttrValue );
462cdf0e10cSrcweir }
463cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue );
464cdf0e10cSrcweir break;
465cdf0e10cSrcweir
466cdf0e10cSrcweir case XML_ATACTION_CAPTION_ESCAPE_OASIS:
467cdf0e10cSrcweir {
468cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
469cdf0e10cSrcweir if( aAttrValue.indexOf( sal_Unicode('%') ) != -1 )
470cdf0e10cSrcweir {
471cdf0e10cSrcweir sal_Int32 nValue = 0;
472cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, rAttrValue );
473cdf0e10cSrcweir if( nValue )
474cdf0e10cSrcweir {
475cdf0e10cSrcweir nValue *= 100;
476cdf0e10cSrcweir rtl::OUStringBuffer aOut;
477cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue );
478cdf0e10cSrcweir aAttrValue = aOut.makeStringAndClear();
479cdf0e10cSrcweir }
480cdf0e10cSrcweir }
481cdf0e10cSrcweir else
482cdf0e10cSrcweir {
483cdf0e10cSrcweir XMLTransformerBase::ReplaceSingleInWithInch( aAttrValue );
484cdf0e10cSrcweir }
485cdf0e10cSrcweir
486cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aAttrValue );
487cdf0e10cSrcweir }
488cdf0e10cSrcweir break;
489cdf0e10cSrcweir
490cdf0e10cSrcweir case XML_ATACTION_DECODE_PROTECT:
491cdf0e10cSrcweir {
492cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue );
493cdf0e10cSrcweir
494cdf0e10cSrcweir if( rAttrValue.indexOf( GetXMLToken( XML_SIZE ) ) != -1 )
495cdf0e10cSrcweir pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
496cdf0e10cSrcweir XML_NAMESPACE_DRAW,
497cdf0e10cSrcweir GetXMLToken( XML_SIZE_PROTECT )), GetXMLToken( XML_TRUE ) );
498cdf0e10cSrcweir
499cdf0e10cSrcweir if( rAttrValue.indexOf( GetXMLToken( XML_POSITION ) ) != -1 )
500cdf0e10cSrcweir pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
501cdf0e10cSrcweir XML_NAMESPACE_DRAW,
502cdf0e10cSrcweir GetXMLToken( XML_MOVE_PROTECT )), GetXMLToken( XML_TRUE ) );
503cdf0e10cSrcweir }
504cdf0e10cSrcweir break;
505cdf0e10cSrcweir
506cdf0e10cSrcweir case XML_ATACTION_DRAW_MIRROR_OASIS: // renames style:mirror to draw:mirror and adapts values
507cdf0e10cSrcweir {
508cdf0e10cSrcweir // keep original for writer graphic objects
509cdf0e10cSrcweir // --> OD 2005-05-12 #i49139# - adapts attribute values,
510cdf0e10cSrcweir OUString aNewAttrValue;
511cdf0e10cSrcweir SvXMLTokenEnumerator aTokenEnum( rAttrValue );
512cdf0e10cSrcweir OUString aToken;
513cdf0e10cSrcweir while( aTokenEnum.getNextToken( aToken ) )
514cdf0e10cSrcweir {
515cdf0e10cSrcweir if ( aNewAttrValue.getLength() > 0 )
516cdf0e10cSrcweir {
517cdf0e10cSrcweir aNewAttrValue += rtl::OUString::createFromAscii( " " );
518cdf0e10cSrcweir }
519cdf0e10cSrcweir
520cdf0e10cSrcweir if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_EVEN ) )
521cdf0e10cSrcweir {
522cdf0e10cSrcweir aNewAttrValue += GetXMLToken( XML_HORIZONTAL_ON_LEFT_PAGES );
523cdf0e10cSrcweir }
524cdf0e10cSrcweir else if ( IsXMLToken( aToken, XML_HORIZONTAL_ON_ODD ) )
525cdf0e10cSrcweir {
526cdf0e10cSrcweir aNewAttrValue += GetXMLToken( XML_HORIZONTAL_ON_RIGHT_PAGES );
527cdf0e10cSrcweir }
528cdf0e10cSrcweir else
529cdf0e10cSrcweir {
530cdf0e10cSrcweir aNewAttrValue += aToken;
531cdf0e10cSrcweir }
532cdf0e10cSrcweir }
533cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aNewAttrValue );
534cdf0e10cSrcweir // <--
535cdf0e10cSrcweir
536cdf0e10cSrcweir // create old draw:mirror for drawing graphic objects
537cdf0e10cSrcweir OUString aAttrValue( GetXMLToken( IsXMLToken( rAttrValue, XML_HORIZONTAL ) ? XML_TRUE : XML_FALSE ) );
538cdf0e10cSrcweir pAttrList->AddAttribute( GetTransformer().GetNamespaceMap().GetQNameByKey(
539cdf0e10cSrcweir XML_NAMESPACE_DRAW,
540cdf0e10cSrcweir GetXMLToken( XML_MIRROR )), aAttrValue );
541cdf0e10cSrcweir }
542cdf0e10cSrcweir break;
543cdf0e10cSrcweir case XML_ATACTION_GAMMA_OASIS: // converts percentage value to double
544cdf0e10cSrcweir {
545cdf0e10cSrcweir sal_Int32 nValue;
546cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, rAttrValue );
547cdf0e10cSrcweir const double fValue = ((double)nValue) / 100.0;
548cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, OUString::valueOf( fValue ) );
549cdf0e10cSrcweir }
550cdf0e10cSrcweir break;
551cdf0e10cSrcweir case XML_ATACTION_OPACITY_FIX:
552cdf0e10cSrcweir {
553cdf0e10cSrcweir sal_Int32 nValue;
554cdf0e10cSrcweir if( rAttrValue.indexOf( sal_Unicode('%') ) != -1 )
555cdf0e10cSrcweir {
556cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( nValue, rAttrValue );
557cdf0e10cSrcweir }
558cdf0e10cSrcweir else
559cdf0e10cSrcweir {
560cdf0e10cSrcweir nValue = sal_Int32( rAttrValue.toDouble() * 100.0 );
561cdf0e10cSrcweir }
562cdf0e10cSrcweir nValue = 100 - nValue;
563cdf0e10cSrcweir
564cdf0e10cSrcweir rtl::OUStringBuffer aOut;
565cdf0e10cSrcweir SvXMLUnitConverter::convertPercent( aOut, nValue );
566cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, aOut.makeStringAndClear() );
567cdf0e10cSrcweir }
568cdf0e10cSrcweir break;
569cdf0e10cSrcweir default:
570cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" );
571cdf0e10cSrcweir break;
572cdf0e10cSrcweir }
573cdf0e10cSrcweir }
574cdf0e10cSrcweir else
575cdf0e10cSrcweir {
576cdf0e10cSrcweir pAttrList->AddAttribute( rAttrName, rAttrValue );
577cdf0e10cSrcweir }
578cdf0e10cSrcweir }
579cdf0e10cSrcweir if( XML_TOKEN_END != eUnderline )
580cdf0e10cSrcweir pAttrList->AddAttribute(
581cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
582cdf0e10cSrcweir XML_NAMESPACE_STYLE,
583cdf0e10cSrcweir GetXMLToken( XML_TEXT_UNDERLINE ) ),
584cdf0e10cSrcweir MergeUnderline( eUnderline, bBoldUnderline,
585cdf0e10cSrcweir bDoubleUnderline ) );
586cdf0e10cSrcweir if( XML_TOKEN_END != eLineThrough )
587cdf0e10cSrcweir pAttrList->AddAttribute(
588cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
589cdf0e10cSrcweir XML_NAMESPACE_STYLE,
590cdf0e10cSrcweir GetXMLToken( XML_TEXT_CROSSING_OUT ) ),
591cdf0e10cSrcweir MergeLineThrough( eLineThrough, bBoldLineThrough,
592cdf0e10cSrcweir bDoubleLineThrough, cLineThroughChar ) );
593cdf0e10cSrcweir if( bIntervalMinorFound )
594cdf0e10cSrcweir {
595cdf0e10cSrcweir double fIntervalMinor = 0.0;
596cdf0e10cSrcweir if( nIntervalMinorDivisor != 0)
597cdf0e10cSrcweir fIntervalMinor = fIntervalMajor / static_cast< double >( nIntervalMinorDivisor );
598cdf0e10cSrcweir
599cdf0e10cSrcweir ::rtl::OUStringBuffer aBuf;
600cdf0e10cSrcweir SvXMLUnitConverter::convertDouble( aBuf, fIntervalMinor );
601cdf0e10cSrcweir pAttrList->AddAttribute(
602cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
603cdf0e10cSrcweir XML_NAMESPACE_CHART,
604cdf0e10cSrcweir GetXMLToken( XML_INTERVAL_MINOR )),
605cdf0e10cSrcweir aBuf.makeStringAndClear());
606cdf0e10cSrcweir }
607cdf0e10cSrcweir
608cdf0e10cSrcweir // #i25616#
609cdf0e10cSrcweir if(aOpacityValueRemember.getLength() || aImageOpacityValueRemember.getLength())
610cdf0e10cSrcweir {
611cdf0e10cSrcweir pAttrList->AddAttribute(
612cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetQNameByKey(
613cdf0e10cSrcweir XML_NAMESPACE_DRAW,
614cdf0e10cSrcweir GetXMLToken( XML_TRANSPARENCY ) ),
615cdf0e10cSrcweir aImageOpacityValueRemember.getLength()
616cdf0e10cSrcweir ? aImageOpacityValueRemember : aOpacityValueRemember );
617cdf0e10cSrcweir }
618cdf0e10cSrcweir }
619cdf0e10cSrcweir else
620cdf0e10cSrcweir {
621cdf0e10cSrcweir if( !m_xAttrList.is() )
622cdf0e10cSrcweir {
623cdf0e10cSrcweir m_xAttrList = new XMLMutableAttributeList( rAttrList, sal_True );
624cdf0e10cSrcweir }
625cdf0e10cSrcweir else
626cdf0e10cSrcweir {
627cdf0e10cSrcweir static_cast< XMLMutableAttributeList * >( m_xAttrList.get() )
628cdf0e10cSrcweir ->AppendAttributeList( rAttrList );
629cdf0e10cSrcweir }
630cdf0e10cSrcweir }
631cdf0e10cSrcweir }
632cdf0e10cSrcweir
Export()633cdf0e10cSrcweir void XMLPropertiesTContext_Impl::Export()
634cdf0e10cSrcweir {
635cdf0e10cSrcweir OUString aNewQName( GetTransformer().GetNamespaceMap().GetQNameByKey(
636cdf0e10cSrcweir XML_NAMESPACE_STYLE,
637cdf0e10cSrcweir ::xmloff::token::GetXMLToken( XML_PROPERTIES ) ) );
638cdf0e10cSrcweir GetTransformer().GetDocHandler()->startElement( GetExportQName(),
639cdf0e10cSrcweir m_xAttrList );
640cdf0e10cSrcweir ExportContent();
641cdf0e10cSrcweir GetTransformer().GetDocHandler()->endElement( GetExportQName() );
642cdf0e10cSrcweir }
643cdf0e10cSrcweir
GetPropType(const OUString & rLocalName)644cdf0e10cSrcweir XMLPropType XMLPropertiesTContext_Impl::GetPropType( const OUString& rLocalName )
645cdf0e10cSrcweir {
646cdf0e10cSrcweir XMLPropType eProp = XML_PROP_TYPE_END;
647cdf0e10cSrcweir if( IsXMLToken( rLocalName, XML_GRAPHIC_PROPERTIES ) )
648cdf0e10cSrcweir eProp = XML_PROP_TYPE_GRAPHIC;
649cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_DRAWING_PAGE_PROPERTIES ) )
650cdf0e10cSrcweir eProp = XML_PROP_TYPE_DRAWING_PAGE;
651cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PAGE_LAYOUT_PROPERTIES ) )
652cdf0e10cSrcweir eProp = XML_PROP_TYPE_PAGE_LAYOUT;
653cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_HEADER_FOOTER_PROPERTIES ) )
654cdf0e10cSrcweir eProp = XML_PROP_TYPE_HEADER_FOOTER;
655cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TEXT_PROPERTIES ) )
656cdf0e10cSrcweir eProp = XML_PROP_TYPE_TEXT;
657cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_PARAGRAPH_PROPERTIES ) )
658cdf0e10cSrcweir eProp = XML_PROP_TYPE_PARAGRAPH;
659cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_RUBY_PROPERTIES ) )
660cdf0e10cSrcweir eProp = XML_PROP_TYPE_RUBY;
661cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_SECTION_PROPERTIES ) )
662cdf0e10cSrcweir eProp = XML_PROP_TYPE_SECTION;
663cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_PROPERTIES ) )
664cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE;
665cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_COLUMN_PROPERTIES ) )
666cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE_COLUMN;
667cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_ROW_PROPERTIES ) )
668cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE_ROW;
669cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_TABLE_CELL_PROPERTIES ) )
670cdf0e10cSrcweir eProp = XML_PROP_TYPE_TABLE_CELL;
671cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_LIST_LEVEL_PROPERTIES ) )
672cdf0e10cSrcweir eProp = XML_PROP_TYPE_LIST_LEVEL;
673cdf0e10cSrcweir else if( IsXMLToken( rLocalName, XML_CHART_PROPERTIES ) )
674cdf0e10cSrcweir eProp = XML_PROP_TYPE_CHART;
675cdf0e10cSrcweir
676cdf0e10cSrcweir return eProp;
677cdf0e10cSrcweir }
678cdf0e10cSrcweir
MergeUnderline(XMLTokenEnum eUnderline,sal_Bool bBold,sal_Bool bDouble)679cdf0e10cSrcweir OUString XMLPropertiesTContext_Impl::MergeUnderline(
680cdf0e10cSrcweir XMLTokenEnum eUnderline, sal_Bool bBold, sal_Bool bDouble )
681cdf0e10cSrcweir {
682cdf0e10cSrcweir if( bDouble )
683cdf0e10cSrcweir {
684cdf0e10cSrcweir switch( eUnderline )
685cdf0e10cSrcweir {
686cdf0e10cSrcweir case XML_WAVE:
687cdf0e10cSrcweir eUnderline = XML_DOUBLE_WAVE;
688cdf0e10cSrcweir break;
689cdf0e10cSrcweir default:
690cdf0e10cSrcweir eUnderline = XML_DOUBLE;
691cdf0e10cSrcweir break;
692cdf0e10cSrcweir }
693cdf0e10cSrcweir }
694cdf0e10cSrcweir else if( bBold )
695cdf0e10cSrcweir {
696cdf0e10cSrcweir switch( eUnderline )
697cdf0e10cSrcweir {
698cdf0e10cSrcweir case XML_NONE:
699cdf0e10cSrcweir case XML_SOLID:
700cdf0e10cSrcweir eUnderline = XML_BOLD;
701cdf0e10cSrcweir break;
702cdf0e10cSrcweir case XML_DOTTED:
703cdf0e10cSrcweir eUnderline = XML_BOLD_DOTTED;
704cdf0e10cSrcweir break;
705cdf0e10cSrcweir case XML_DASH:
706cdf0e10cSrcweir eUnderline = XML_BOLD_DASH;
707cdf0e10cSrcweir break;
708cdf0e10cSrcweir case XML_LONG_DASH:
709cdf0e10cSrcweir eUnderline = XML_BOLD_LONG_DASH;
710cdf0e10cSrcweir break;
711cdf0e10cSrcweir case XML_DOT_DASH:
712cdf0e10cSrcweir eUnderline = XML_BOLD_DOT_DASH;
713cdf0e10cSrcweir break;
714cdf0e10cSrcweir case XML_DOT_DOT_DASH:
715cdf0e10cSrcweir eUnderline = XML_BOLD_DOT_DOT_DASH;
716cdf0e10cSrcweir break;
717cdf0e10cSrcweir case XML_WAVE:
718cdf0e10cSrcweir eUnderline = XML_BOLD_WAVE;
719cdf0e10cSrcweir break;
720cdf0e10cSrcweir default:
721cdf0e10cSrcweir OSL_ENSURE( false, "xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" );
722cdf0e10cSrcweir break;
723cdf0e10cSrcweir }
724cdf0e10cSrcweir }
725cdf0e10cSrcweir else
726cdf0e10cSrcweir {
727cdf0e10cSrcweir switch( eUnderline )
728cdf0e10cSrcweir {
729cdf0e10cSrcweir case XML_SOLID:
730cdf0e10cSrcweir eUnderline = XML_SINGLE;
731cdf0e10cSrcweir break;
732cdf0e10cSrcweir case XML_NONE:
733cdf0e10cSrcweir eUnderline = XML_NONE;
734cdf0e10cSrcweir break;
735cdf0e10cSrcweir default:
736cdf0e10cSrcweir OSL_ENSURE( false, "xmloff::XMLPropertiesTContext_Impl::MergeUnderline(), missing underline case!" );
737cdf0e10cSrcweir break;
738cdf0e10cSrcweir }
739cdf0e10cSrcweir }
740cdf0e10cSrcweir
741cdf0e10cSrcweir return GetXMLToken( eUnderline );
742cdf0e10cSrcweir }
743cdf0e10cSrcweir
MergeLineThrough(XMLTokenEnum eLineThrough,sal_Bool bBold,sal_Bool bDouble,sal_Unicode c)744cdf0e10cSrcweir OUString XMLPropertiesTContext_Impl::MergeLineThrough(
745cdf0e10cSrcweir XMLTokenEnum eLineThrough, sal_Bool bBold, sal_Bool bDouble,
746cdf0e10cSrcweir sal_Unicode c )
747cdf0e10cSrcweir {
748cdf0e10cSrcweir if( c )
749cdf0e10cSrcweir eLineThrough = c=='/' ? XML_SLASH : XML_uX;
750cdf0e10cSrcweir else if( bDouble )
751cdf0e10cSrcweir eLineThrough = XML_DOUBLE_LINE;
752cdf0e10cSrcweir else if( bBold )
753cdf0e10cSrcweir eLineThrough = XML_THICK_LINE;
754cdf0e10cSrcweir else if( XML_NONE != eLineThrough )
755cdf0e10cSrcweir eLineThrough = XML_SINGLE_LINE;
756cdf0e10cSrcweir
757cdf0e10cSrcweir return GetXMLToken( eLineThrough );
758cdf0e10cSrcweir }
759cdf0e10cSrcweir
760cdf0e10cSrcweir //------------------------------------------------------------------------------
761cdf0e10cSrcweir
762cdf0e10cSrcweir TYPEINIT1( XMLStyleOASISTContext, XMLPersElemContentTContext );
763cdf0e10cSrcweir
XMLStyleOASISTContext(XMLTransformerBase & rImp,const OUString & rQName,sal_Bool bPersistent)764cdf0e10cSrcweir XMLStyleOASISTContext::XMLStyleOASISTContext( XMLTransformerBase& rImp,
765cdf0e10cSrcweir const OUString& rQName,
766cdf0e10cSrcweir sal_Bool bPersistent ) :
767cdf0e10cSrcweir XMLPersElemContentTContext ( rImp, rQName ),
768cdf0e10cSrcweir m_bPersistent( bPersistent ),
769cdf0e10cSrcweir m_bControlStyle( false )
770cdf0e10cSrcweir {
771cdf0e10cSrcweir }
772cdf0e10cSrcweir
XMLStyleOASISTContext(XMLTransformerBase & rImp,const OUString & rQName,sal_uInt16 nPrefix,::xmloff::token::XMLTokenEnum eToken,sal_Bool bPersistent)773cdf0e10cSrcweir XMLStyleOASISTContext::XMLStyleOASISTContext(
774cdf0e10cSrcweir XMLTransformerBase& rImp,
775cdf0e10cSrcweir const OUString& rQName,
776cdf0e10cSrcweir sal_uInt16 nPrefix,
777cdf0e10cSrcweir ::xmloff::token::XMLTokenEnum eToken,
778cdf0e10cSrcweir sal_Bool bPersistent ) :
779cdf0e10cSrcweir XMLPersElemContentTContext( rImp, rQName, nPrefix, eToken ),
780cdf0e10cSrcweir m_bPersistent( bPersistent )
781cdf0e10cSrcweir {
782cdf0e10cSrcweir }
783cdf0e10cSrcweir
~XMLStyleOASISTContext()784cdf0e10cSrcweir XMLStyleOASISTContext::~XMLStyleOASISTContext()
785cdf0e10cSrcweir {
786cdf0e10cSrcweir }
787cdf0e10cSrcweir
CreateChildContext(sal_uInt16 nPrefix,const OUString & rLocalName,const OUString & rQName,const Reference<XAttributeList> & rAttrList)788cdf0e10cSrcweir XMLTransformerContext *XMLStyleOASISTContext::CreateChildContext(
789cdf0e10cSrcweir sal_uInt16 nPrefix,
790cdf0e10cSrcweir const OUString& rLocalName,
791cdf0e10cSrcweir const OUString& rQName,
792cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList )
793cdf0e10cSrcweir {
794cdf0e10cSrcweir XMLTransformerContext *pContext = 0;
795cdf0e10cSrcweir
796cdf0e10cSrcweir if( XML_NAMESPACE_STYLE == nPrefix )
797cdf0e10cSrcweir {
798cdf0e10cSrcweir XMLPropType ePropType =
799cdf0e10cSrcweir XMLPropertiesTContext_Impl::GetPropType( rLocalName );
800cdf0e10cSrcweir if( XML_PROP_TYPE_END != ePropType )
801cdf0e10cSrcweir {
802cdf0e10cSrcweir // if no properties context exist start a new one.
803cdf0e10cSrcweir if( !m_xPropContext.is() )
804cdf0e10cSrcweir m_xPropContext = new XMLPropertiesTContext_Impl(
805cdf0e10cSrcweir GetTransformer(), rQName, ePropType, m_aStyleFamily, m_bControlStyle );
806cdf0e10cSrcweir else
807cdf0e10cSrcweir m_xPropContext->SetQNameAndPropType( rQName, ePropType );
808cdf0e10cSrcweir pContext = m_xPropContext.get();
809cdf0e10cSrcweir }
810cdf0e10cSrcweir }
811cdf0e10cSrcweir if( !pContext )
812cdf0e10cSrcweir {
813cdf0e10cSrcweir // if a properties context exist close it
814cdf0e10cSrcweir if( m_xPropContext.is() && !m_bPersistent )
815cdf0e10cSrcweir {
816cdf0e10cSrcweir m_xPropContext->Export();
817cdf0e10cSrcweir m_xPropContext = 0;
818cdf0e10cSrcweir }
819cdf0e10cSrcweir
820cdf0e10cSrcweir pContext = m_bPersistent
821cdf0e10cSrcweir ? XMLPersElemContentTContext::CreateChildContext(
822cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList )
823cdf0e10cSrcweir : XMLTransformerContext::CreateChildContext(
824cdf0e10cSrcweir nPrefix, rLocalName, rQName, rAttrList );
825cdf0e10cSrcweir }
826cdf0e10cSrcweir
827cdf0e10cSrcweir return pContext;
828cdf0e10cSrcweir }
829cdf0e10cSrcweir
StartElement(const Reference<XAttributeList> & rAttrList)830cdf0e10cSrcweir void XMLStyleOASISTContext::StartElement(
831cdf0e10cSrcweir const Reference< XAttributeList >& rAttrList )
832cdf0e10cSrcweir {
833cdf0e10cSrcweir XMLTransformerActions *pActions =
834cdf0e10cSrcweir GetTransformer().GetUserDefinedActions( OASIS_STYLE_ACTIONS );
835cdf0e10cSrcweir OSL_ENSURE( pActions, "go no actions" );
836cdf0e10cSrcweir
837cdf0e10cSrcweir Reference< XAttributeList > xAttrList( rAttrList );
838cdf0e10cSrcweir XMLMutableAttributeList *pMutableAttrList = 0;
839cdf0e10cSrcweir sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0;
840cdf0e10cSrcweir sal_Int16 nFamilyAttr = -1;
841cdf0e10cSrcweir m_bControlStyle = sal_False;
842cdf0e10cSrcweir
843cdf0e10cSrcweir for( sal_Int16 i=0; i < nAttrCount; i++ )
844cdf0e10cSrcweir {
845cdf0e10cSrcweir const OUString& rAttrName = xAttrList->getNameByIndex( i );
846cdf0e10cSrcweir OUString aLocalName;
847cdf0e10cSrcweir sal_uInt16 nPrefix =
848cdf0e10cSrcweir GetTransformer().GetNamespaceMap().GetKeyByAttrName( rAttrName,
849cdf0e10cSrcweir &aLocalName );
850cdf0e10cSrcweir XMLTransformerActions::key_type aKey( nPrefix, aLocalName );
851cdf0e10cSrcweir XMLTransformerActions::const_iterator aIter =
852cdf0e10cSrcweir pActions->find( aKey );
853cdf0e10cSrcweir if( !(aIter == pActions->end() ) )
854cdf0e10cSrcweir {
855cdf0e10cSrcweir if( !pMutableAttrList )
856cdf0e10cSrcweir {
857cdf0e10cSrcweir pMutableAttrList =
858cdf0e10cSrcweir new XMLMutableAttributeList( xAttrList );
859cdf0e10cSrcweir xAttrList = pMutableAttrList;
860cdf0e10cSrcweir }
861cdf0e10cSrcweir const OUString& rAttrValue = xAttrList->getValueByIndex( i );
862cdf0e10cSrcweir switch( (*aIter).second.m_nActionType )
863cdf0e10cSrcweir {
864cdf0e10cSrcweir case XML_ATACTION_STYLE_FAMILY:
865cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_GRAPHIC ) )
866cdf0e10cSrcweir {
867cdf0e10cSrcweir m_aStyleFamily = GetXMLToken( XML_GRAPHICS ) ;
868cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, m_aStyleFamily );
869cdf0e10cSrcweir }
870cdf0e10cSrcweir else
871cdf0e10cSrcweir {
872cdf0e10cSrcweir m_aStyleFamily = rAttrValue;
873cdf0e10cSrcweir
874cdf0e10cSrcweir if( IsXMLToken( rAttrValue, XML_PARAGRAPH ) )
875cdf0e10cSrcweir nFamilyAttr = i;
876cdf0e10cSrcweir }
877cdf0e10cSrcweir
878cdf0e10cSrcweir break;
879cdf0e10cSrcweir case XML_ATACTION_STYLE_DISPLAY_NAME:
880cdf0e10cSrcweir case XML_ATACTION_REMOVE:
881cdf0e10cSrcweir pMutableAttrList->RemoveAttributeByIndex( i );
882cdf0e10cSrcweir --i;
883cdf0e10cSrcweir --nAttrCount;
884cdf0e10cSrcweir break;
885cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME:
886cdf0e10cSrcweir m_bControlStyle = 0 == rAttrValue.compareToAscii( "ctrl", 4 );
887cdf0e10cSrcweir case XML_ATACTION_DECODE_STYLE_NAME_REF:
888cdf0e10cSrcweir {
889cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
890cdf0e10cSrcweir if( GetTransformer().DecodeStyleName(aAttrValue) )
891cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
892cdf0e10cSrcweir }
893cdf0e10cSrcweir break;
894cdf0e10cSrcweir case XML_ATACTION_IN2INCH:
895cdf0e10cSrcweir {
896cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
897cdf0e10cSrcweir if( XMLTransformerBase::ReplaceSingleInWithInch(
898cdf0e10cSrcweir aAttrValue ) )
899cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
900cdf0e10cSrcweir }
901cdf0e10cSrcweir break;
902cdf0e10cSrcweir case XML_ATACTION_NEG_PERCENT:
903cdf0e10cSrcweir {
904cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
905cdf0e10cSrcweir if( GetTransformer().NegPercent(aAttrValue) )
906cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
907cdf0e10cSrcweir }
908cdf0e10cSrcweir break;
909cdf0e10cSrcweir case XML_ATACTION_URI_OASIS:
910cdf0e10cSrcweir {
911cdf0e10cSrcweir OUString aAttrValue( rAttrValue );
912cdf0e10cSrcweir if( GetTransformer().ConvertURIToOOo( aAttrValue,
913cdf0e10cSrcweir static_cast< sal_Bool >((*aIter).second.m_nParam1)))
914cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( i, aAttrValue );
915cdf0e10cSrcweir }
916cdf0e10cSrcweir break;
917cdf0e10cSrcweir default:
918cdf0e10cSrcweir OSL_ENSURE( !this, "unknown action" );
919cdf0e10cSrcweir break;
920cdf0e10cSrcweir }
921cdf0e10cSrcweir }
922cdf0e10cSrcweir }
923cdf0e10cSrcweir
924cdf0e10cSrcweir if( m_bControlStyle && nFamilyAttr != -1 )
925cdf0e10cSrcweir pMutableAttrList->SetValueByIndex( nFamilyAttr, GetXMLToken( XML_CONTROL ) );
926cdf0e10cSrcweir
927cdf0e10cSrcweir
928cdf0e10cSrcweir if( m_bPersistent )
929cdf0e10cSrcweir XMLPersElemContentTContext::StartElement( xAttrList );
930cdf0e10cSrcweir else
931cdf0e10cSrcweir GetTransformer().GetDocHandler()->startElement( GetExportQName(),
932cdf0e10cSrcweir xAttrList );
933cdf0e10cSrcweir }
934cdf0e10cSrcweir
EndElement()935cdf0e10cSrcweir void XMLStyleOASISTContext::EndElement()
936cdf0e10cSrcweir {
937cdf0e10cSrcweir if( m_bPersistent )
938cdf0e10cSrcweir {
939cdf0e10cSrcweir XMLPersElemContentTContext::EndElement();
940cdf0e10cSrcweir }
941cdf0e10cSrcweir else
942cdf0e10cSrcweir {
943cdf0e10cSrcweir // if a properties context exist close it
944cdf0e10cSrcweir if( m_xPropContext.is() )
945cdf0e10cSrcweir {
946cdf0e10cSrcweir m_xPropContext->Export();
947cdf0e10cSrcweir m_xPropContext = 0;
948cdf0e10cSrcweir }
949cdf0e10cSrcweir GetTransformer().GetDocHandler()->endElement( GetExportQName() );
950cdf0e10cSrcweir }
951cdf0e10cSrcweir }
952cdf0e10cSrcweir
Characters(const OUString &)953cdf0e10cSrcweir void XMLStyleOASISTContext::Characters( const OUString& )
954cdf0e10cSrcweir {
955cdf0e10cSrcweir // element content only:
956cdf0e10cSrcweir }
957cdf0e10cSrcweir
ExportContent()958cdf0e10cSrcweir void XMLStyleOASISTContext::ExportContent()
959cdf0e10cSrcweir {
960cdf0e10cSrcweir if( m_xPropContext.is() )
961cdf0e10cSrcweir m_xPropContext->Export();
962cdf0e10cSrcweir XMLPersElemContentTContext::ExportContent();
963cdf0e10cSrcweir }
964cdf0e10cSrcweir
IsPersistent() const965cdf0e10cSrcweir sal_Bool XMLStyleOASISTContext::IsPersistent() const
966cdf0e10cSrcweir {
967cdf0e10cSrcweir return m_bPersistent;
968cdf0e10cSrcweir }
969cdf0e10cSrcweir
CreateTransformerActions(sal_uInt16 nType)970cdf0e10cSrcweir XMLTransformerActions *XMLStyleOASISTContext::CreateTransformerActions(
971cdf0e10cSrcweir sal_uInt16 nType )
972cdf0e10cSrcweir {
973cdf0e10cSrcweir XMLTransformerActionInit *pInit = 0;
974cdf0e10cSrcweir
975cdf0e10cSrcweir switch( nType )
976cdf0e10cSrcweir {
977cdf0e10cSrcweir case PROP_OASIS_GRAPHIC_ATTR_ACTIONS:
978cdf0e10cSrcweir pInit = aGraphicPropertyOASISAttrActionTable;
979cdf0e10cSrcweir break;
980cdf0e10cSrcweir case PROP_OASIS_DRAWING_PAGE_ATTR_ACTIONS:
981cdf0e10cSrcweir pInit = aDrawingPagePropertyOASISAttrActionTable;
982cdf0e10cSrcweir break;
983cdf0e10cSrcweir case PROP_OASIS_PAGE_LAYOUT_ATTR_ACTIONS:
984cdf0e10cSrcweir pInit = aPageLayoutPropertyOASISAttrActionTable;
985cdf0e10cSrcweir break;
986cdf0e10cSrcweir case PROP_OASIS_HEADER_FOOTER_ATTR_ACTIONS:
987cdf0e10cSrcweir pInit = aHeaderFooterPropertyOASISAttrActionTable;
988cdf0e10cSrcweir break;
989cdf0e10cSrcweir case PROP_OASIS_TEXT_ATTR_ACTIONS:
990cdf0e10cSrcweir pInit = aTextPropertyOASISAttrActionTable;
991cdf0e10cSrcweir break;
992cdf0e10cSrcweir case PROP_OASIS_PARAGRAPH_ATTR_ACTIONS:
993cdf0e10cSrcweir pInit = aParagraphPropertyOASISAttrActionTable;
994cdf0e10cSrcweir break;
995cdf0e10cSrcweir case PROP_OASIS_SECTION_ATTR_ACTIONS:
996cdf0e10cSrcweir pInit = aSectionPropertyOASISAttrActionTable;
997cdf0e10cSrcweir break;
998cdf0e10cSrcweir case PROP_OASIS_TABLE_ATTR_ACTIONS:
999cdf0e10cSrcweir pInit = aTablePropertyOASISAttrActionTable;
1000cdf0e10cSrcweir break;
1001cdf0e10cSrcweir case PROP_OASIS_TABLE_COLUMN_ATTR_ACTIONS:
1002cdf0e10cSrcweir pInit = aTableColumnPropertyOASISAttrActionTable;
1003cdf0e10cSrcweir break;
1004cdf0e10cSrcweir case PROP_OASIS_TABLE_ROW_ATTR_ACTIONS:
1005cdf0e10cSrcweir pInit = aTableRowPropertyOASISAttrActionTable;
1006cdf0e10cSrcweir break;
1007cdf0e10cSrcweir case PROP_OASIS_TABLE_CELL_ATTR_ACTIONS:
1008cdf0e10cSrcweir pInit = aTableCellPropertyOASISAttrActionTable;
1009cdf0e10cSrcweir break;
1010cdf0e10cSrcweir case PROP_OASIS_LIST_LEVEL_ATTR_ACTIONS:
1011cdf0e10cSrcweir pInit = aListLevelPropertyOASISAttrActionTable;
1012cdf0e10cSrcweir break;
1013cdf0e10cSrcweir case PROP_OASIS_CHART_ATTR_ACTIONS:
1014cdf0e10cSrcweir pInit = aChartPropertyOASISAttrActionTable;
1015cdf0e10cSrcweir break;
1016cdf0e10cSrcweir }
1017cdf0e10cSrcweir
1018cdf0e10cSrcweir XMLTransformerActions *pActions = 0;
1019cdf0e10cSrcweir if( pInit )
1020cdf0e10cSrcweir pActions = new XMLTransformerActions( pInit );
1021cdf0e10cSrcweir
1022cdf0e10cSrcweir return pActions;
1023cdf0e10cSrcweir }
1024