fix baseline build (old cairo) - 'cairo_rectangle_int_t' does not name a type
[LibreOffice.git] / sc / source / filter / xml / XMLTableSourceContext.cxx
blob1051977371f73d135ea6c44569663fd00f890ac3
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #include "XMLTableSourceContext.hxx"
21 #include "xmlimprt.hxx"
22 #include "document.hxx"
23 #include "xmlsubti.hxx"
24 #include "tablink.hxx"
25 #include <xmloff/xmltoken.hxx>
26 #include <xmloff/xmlnmspe.hxx>
27 #include <xmloff/nmspmap.hxx>
28 #include <sax/tools/converter.hxx>
29 #include <com/sun/star/sheet/XSheetLinkable.hpp>
31 using namespace com::sun::star;
32 using namespace xmloff::token;
34 ScXMLTableSourceContext::ScXMLTableSourceContext( ScXMLImport& rImport,
35 sal_uInt16 nPrfx,
36 const OUString& rLName,
37 const ::com::sun::star::uno::Reference<
38 ::com::sun::star::xml::sax::XAttributeList>& xAttrList) :
39 SvXMLImportContext( rImport, nPrfx, rLName ),
40 sLink(),
41 sTableName(),
42 sFilterName(),
43 sFilterOptions(),
44 nRefresh(0),
45 nMode(sheet::SheetLinkMode_NORMAL)
47 sal_Int16 nAttrCount(xAttrList.is() ? xAttrList->getLength() : 0);
48 for( sal_Int16 i=0; i < nAttrCount; ++i )
50 const OUString& sAttrName(xAttrList->getNameByIndex( i ));
51 OUString aLocalName;
52 sal_uInt16 nPrefix(GetScImport().GetNamespaceMap().GetKeyByAttrName(
53 sAttrName, &aLocalName ));
54 const OUString& sValue(xAttrList->getValueByIndex( i ));
55 if(nPrefix == XML_NAMESPACE_XLINK)
57 if (IsXMLToken(aLocalName, XML_HREF))
58 sLink = GetScImport().GetAbsoluteReference(sValue);
60 else if (nPrefix == XML_NAMESPACE_TABLE)
62 if (IsXMLToken(aLocalName, XML_TABLE_NAME))
63 sTableName = sValue;
64 else if (IsXMLToken(aLocalName, XML_FILTER_NAME))
65 sFilterName = sValue;
66 else if (IsXMLToken(aLocalName, XML_FILTER_OPTIONS))
67 sFilterOptions = sValue;
68 else if (IsXMLToken(aLocalName, XML_MODE))
70 if (IsXMLToken(sValue, XML_COPY_RESULTS_ONLY))
71 nMode = sheet::SheetLinkMode_VALUE;
73 else if (IsXMLToken(aLocalName, XML_REFRESH_DELAY))
75 double fTime;
76 if (::sax::Converter::convertDuration( fTime, sValue ))
77 nRefresh = std::max( (sal_Int32)(fTime * 86400.0), (sal_Int32)0 );
83 ScXMLTableSourceContext::~ScXMLTableSourceContext()
87 SvXMLImportContext *ScXMLTableSourceContext::CreateChildContext( sal_uInt16 nPrefix,
88 const OUString& rLName,
89 const ::com::sun::star::uno::Reference<
90 ::com::sun::star::xml::sax::XAttributeList>& /* xAttrList */ )
92 return new SvXMLImportContext( GetImport(), nPrefix, rLName );
95 void ScXMLTableSourceContext::EndElement()
97 if (!sLink.isEmpty())
99 uno::Reference <sheet::XSheetLinkable> xLinkable (GetScImport().GetTables().GetCurrentXSheet(), uno::UNO_QUERY);
100 ScDocument* pDoc(GetScImport().GetDocument());
101 if (xLinkable.is() && pDoc)
103 ScXMLImport::MutexGuard aGuard(GetScImport());
104 if (pDoc->RenameTab( GetScImport().GetTables().GetCurrentSheet(),
105 GetScImport().GetTables().GetCurrentSheetName(), false, true))
107 sLink = ScGlobal::GetAbsDocName( sLink, pDoc->GetDocumentShell() );
108 if (sFilterName.isEmpty())
109 ScDocumentLoader::GetFilterName( sLink, sFilterName, sFilterOptions, false, false );
111 sal_uInt8 nLinkMode = SC_LINK_NONE;
112 if ( nMode == sheet::SheetLinkMode_NORMAL )
113 nLinkMode = SC_LINK_NORMAL;
114 else if ( nMode == sheet::SheetLinkMode_VALUE )
115 nLinkMode = SC_LINK_VALUE;
117 pDoc->SetLink( GetScImport().GetTables().GetCurrentSheet(),
118 nLinkMode, sLink, sFilterName, sFilterOptions,
119 sTableName, nRefresh );
125 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */