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: xmllabri.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 // MARKER(update_precomp.py): autogen include statement, do not remove
32 #include "precompiled_sc.hxx"
35 //___________________________________________________________________
36 #include "xmllabri.hxx"
37 #include <xmloff/nmspmap.hxx>
38 #include <xmloff/xmltoken.hxx>
39 #include "xmlimprt.hxx"
41 using namespace ::com::sun::star
;
42 using ::rtl::OUString
;
43 using namespace xmloff::token
;
46 //___________________________________________________________________
48 ScXMLLabelRangesContext::ScXMLLabelRangesContext(
51 const OUString
& rLName
,
52 const uno::Reference
< xml::sax::XAttributeList
>& /* xAttrList */ ):
53 SvXMLImportContext( rImport
, nPrefix
, rLName
)
55 rImport
.LockSolarMutex();
58 ScXMLLabelRangesContext::~ScXMLLabelRangesContext()
60 GetScImport().UnlockSolarMutex();
63 SvXMLImportContext
* ScXMLLabelRangesContext::CreateChildContext(
65 const OUString
& rLName
,
66 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
)
68 SvXMLImportContext
* pContext(NULL
);
69 const SvXMLTokenMap
& rTokenMap(GetScImport().GetLabelRangesElemTokenMap());
71 switch( rTokenMap
.Get( nPrefix
, rLName
) )
73 case XML_TOK_LABEL_RANGE_ELEM
:
74 pContext
= new ScXMLLabelRangeContext( GetScImport(), nPrefix
, rLName
, xAttrList
);
78 pContext
= new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
83 void ScXMLLabelRangesContext::EndElement()
88 //___________________________________________________________________
90 ScXMLLabelRangeContext::ScXMLLabelRangeContext(
93 const OUString
& rLName
,
94 const uno::Reference
< xml::sax::XAttributeList
>& xAttrList
) :
95 SvXMLImportContext( rImport
, nPrfx
, rLName
),
96 bColumnOrientation( sal_False
)
98 sal_Int16
nAttrCount(xAttrList
.is() ? xAttrList
->getLength() : 0);
99 const SvXMLTokenMap
& rAttrTokenMap(GetScImport().GetLabelRangeAttrTokenMap());
101 for( sal_Int16 nIndex
= 0; nIndex
< nAttrCount
; ++nIndex
)
103 const rtl::OUString
& sAttrName (xAttrList
->getNameByIndex( nIndex
));
104 const rtl::OUString
& sValue (xAttrList
->getValueByIndex( nIndex
));
106 USHORT
nPrefix (GetScImport().GetNamespaceMap().GetKeyByAttrName( sAttrName
, &aLocalName
));
108 switch( rAttrTokenMap
.Get( nPrefix
, aLocalName
) )
110 case XML_TOK_LABEL_RANGE_ATTR_LABEL_RANGE
:
111 sLabelRangeStr
= sValue
;
113 case XML_TOK_LABEL_RANGE_ATTR_DATA_RANGE
:
114 sDataRangeStr
= sValue
;
116 case XML_TOK_LABEL_RANGE_ATTR_ORIENTATION
:
117 bColumnOrientation
= IsXMLToken(sValue
, XML_COLUMN
);
123 ScXMLLabelRangeContext::~ScXMLLabelRangeContext()
127 SvXMLImportContext
* ScXMLLabelRangeContext::CreateChildContext(
129 const OUString
& rLName
,
130 const uno::Reference
< xml::sax::XAttributeList
>& /* xAttrList */ )
132 return new SvXMLImportContext( GetImport(), nPrefix
, rLName
);
135 void ScXMLLabelRangeContext::EndElement()
137 // #b5071088# Label ranges must be stored as strings until all sheets are loaded
138 // (like named expressions).
140 ScMyLabelRange
* pLabelRange
= new ScMyLabelRange
;
142 pLabelRange
->sLabelRangeStr
= sLabelRangeStr
;
143 pLabelRange
->sDataRangeStr
= sDataRangeStr
;
144 pLabelRange
->bColumnOrientation
= bColumnOrientation
;
146 GetScImport().AddLabelRange(pLabelRange
);