/src/libreoffice/xmloff/source/transform/DlgOASISTContext.cxx
Line | Count | Source |
1 | | /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | /* |
3 | | * This file is part of the LibreOffice project. |
4 | | * |
5 | | * This Source Code Form is subject to the terms of the Mozilla Public |
6 | | * License, v. 2.0. If a copy of the MPL was not distributed with this |
7 | | * file, You can obtain one at http://mozilla.org/MPL/2.0/. |
8 | | * |
9 | | * This file incorporates work covered by the following license notice: |
10 | | * |
11 | | * Licensed to the Apache Software Foundation (ASF) under one or more |
12 | | * contributor license agreements. See the NOTICE file distributed |
13 | | * with this work for additional information regarding copyright |
14 | | * ownership. The ASF licenses this file to you under the Apache |
15 | | * License, Version 2.0 (the "License"); you may not use this file |
16 | | * except in compliance with the License. You may obtain a copy of |
17 | | * the License at http://www.apache.org/licenses/LICENSE-2.0 . |
18 | | */ |
19 | | |
20 | | #include "DlgOASISTContext.hxx" |
21 | | #include "MutableAttrList.hxx" |
22 | | #include "ActionMapTypesOASIS.hxx" |
23 | | #include "AttrTransformerAction.hxx" |
24 | | #include "TransformerActions.hxx" |
25 | | #include "TransformerBase.hxx" |
26 | | #include <osl/diagnose.h> |
27 | | |
28 | | using namespace ::com::sun::star::uno; |
29 | | using namespace ::com::sun::star::xml::sax; |
30 | | using namespace ::xmloff::token; |
31 | | |
32 | | XMLDlgOASISTransformerContext::XMLDlgOASISTransformerContext( |
33 | | XMLTransformerBase& rImp, |
34 | | const OUString& rQName ) : |
35 | 0 | XMLTransformerContext( rImp, rQName ) |
36 | 0 | { |
37 | 0 | } |
38 | | |
39 | | XMLDlgOASISTransformerContext::~XMLDlgOASISTransformerContext() |
40 | 0 | { |
41 | 0 | } |
42 | | |
43 | | void XMLDlgOASISTransformerContext::StartElement( |
44 | | const Reference< XAttributeList >& rAttrList ) |
45 | 0 | { |
46 | 0 | XMLTransformerActions *pActions = |
47 | 0 | GetTransformer().GetUserDefinedActions( OASIS_DLG_ACTIONS ); |
48 | 0 | OSL_ENSURE( pActions, "go no actions" ); |
49 | |
|
50 | 0 | Reference< XAttributeList > xAttrList( rAttrList ); |
51 | 0 | rtl::Reference<XMLMutableAttributeList> pMutableAttrList; |
52 | 0 | sal_Int16 nAttrCount = xAttrList.is() ? xAttrList->getLength() : 0; |
53 | |
|
54 | 0 | for( sal_Int16 i=0; i < nAttrCount; i++ ) |
55 | 0 | { |
56 | 0 | const OUString aAttrName = xAttrList->getNameByIndex( i ); |
57 | 0 | OUString aLocalName; |
58 | 0 | sal_uInt16 nPrefix = |
59 | 0 | GetTransformer().GetNamespaceMap().GetKeyByAttrName( aAttrName, |
60 | 0 | &aLocalName ); |
61 | |
|
62 | 0 | XMLTransformerActions::key_type aKey( nPrefix, aLocalName ); |
63 | 0 | XMLTransformerActions::const_iterator aIter = |
64 | 0 | pActions->find( aKey ); |
65 | |
|
66 | 0 | if( aIter != pActions->end() ) |
67 | 0 | { |
68 | 0 | if( !pMutableAttrList ) |
69 | 0 | { |
70 | 0 | pMutableAttrList = |
71 | 0 | new XMLMutableAttributeList( xAttrList ); |
72 | 0 | xAttrList = pMutableAttrList; |
73 | 0 | } |
74 | 0 | const OUString aAttrValue = xAttrList->getValueByIndex( i ); |
75 | 0 | switch( (*aIter).second.m_nActionType ) |
76 | 0 | { |
77 | 0 | case XML_ATACTION_DLG_BORDER: |
78 | 0 | { |
79 | 0 | if ( aAttrValue != GetXMLToken( XML_NONE ) && |
80 | 0 | aAttrValue != GetXMLToken( XML_SIMPLE ) && |
81 | 0 | aAttrValue != GetXMLToken( XML_3D ) ) |
82 | 0 | { |
83 | 0 | pMutableAttrList->SetValueByIndex( |
84 | 0 | i, GetXMLToken( XML_NONE ) ); |
85 | 0 | } |
86 | 0 | } |
87 | 0 | break; |
88 | 0 | default: |
89 | 0 | OSL_ENSURE( false, "unknown action" ); |
90 | 0 | break; |
91 | 0 | } |
92 | 0 | } |
93 | 0 | } |
94 | | |
95 | 0 | XMLTransformerContext::StartElement( xAttrList ); |
96 | 0 | } |
97 | | |
98 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |