/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. * * This file incorporates work covered by the following license notice: * * Licensed to the Apache Software Foundation (ASF) under one or more * contributor license agreements. See the NOTICE file distributed * with this work for additional information regarding copyright * ownership. The ASF licenses this file to you under the Apache * License, Version 2.0 (the "License"); you may not use this file * except in compliance with the License. You may obtain a copy of * the License at http://www.apache.org/licenses/LICENSE-2.0 . */ #include #include #include #include using namespace com::sun::star::uno; using namespace com::sun::star::xml::sax; using ::rtl::OUString; #define ELEMENT_ACCELERATORLIST "acceleratorlist" #define ELEMENT_ACCELERATORITEM "item" #define ATTRIBUTE_KEYCODE "code" #define ATTRIBUTE_MODIFIER "modifier" #define ATTRIBUTE_URL "url" #define ATTRIBUTE_TYPE_CDATA "CDATA" namespace { struct AttributeListImpl_impl; class AttributeListImpl : public ::cppu::WeakImplHelper1< ::com::sun::star::xml::sax::XAttributeList > { protected: ~AttributeListImpl(); public: AttributeListImpl(); AttributeListImpl( const AttributeListImpl & ); public: virtual sal_Int16 SAL_CALL getLength(void) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getNameByIndex(sal_Int16 i) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTypeByIndex(sal_Int16 i) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getTypeByName(const ::rtl::OUString& aName) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getValueByIndex(sal_Int16 i) throw (::com::sun::star::uno::RuntimeException); virtual ::rtl::OUString SAL_CALL getValueByName(const ::rtl::OUString& aName) throw (::com::sun::star::uno::RuntimeException); public: void addAttribute( const ::rtl::OUString &sName , const ::rtl::OUString &sType , const ::rtl::OUString &sValue ); private: struct AttributeListImpl_impl *m_pImpl; }; struct TagAttribute { TagAttribute(){} TagAttribute( const OUString &aName, const OUString &aType , const OUString &aValue ) { sName = aName; sType = aType; sValue = aValue; } OUString sName; OUString sType; OUString sValue; }; struct AttributeListImpl_impl { AttributeListImpl_impl() { // performance improvement during adding vecAttribute.reserve(20); } ::std::vector vecAttribute; }; sal_Int16 SAL_CALL AttributeListImpl::getLength(void) throw (RuntimeException) { return sal::static_int_cast< sal_Int16 >(m_pImpl->vecAttribute.size()); } AttributeListImpl::AttributeListImpl( const AttributeListImpl &r ) : cppu::WeakImplHelper1(r) { m_pImpl = new AttributeListImpl_impl; *m_pImpl = *(r.m_pImpl); } OUString AttributeListImpl::getNameByIndex(sal_Int16 i) throw (RuntimeException) { if( i < sal::static_int_cast(m_pImpl->vecAttribute.size()) ) { return m_pImpl->vecAttribute[i].sName; } return OUString(); } OUString AttributeListImpl::getTypeByIndex(sal_Int16 i) throw (RuntimeException) { if( i < sal::static_int_cast(m_pImpl->vecAttribute.size()) ) { return m_pImpl->vecAttribute[i].sType; } return OUString(); } OUString AttributeListImpl::getValueByIndex(sal_Int16 i) throw (RuntimeException) { if( i < sal::static_int_cast(m_pImpl->vecAttribute.size()) ) { return m_pImpl->vecAttribute[i].sValue; } return OUString(); } OUString AttributeListImpl::getTypeByName( const OUString& sName ) throw (RuntimeException) { ::std::vector::iterator ii = m_pImpl->vecAttribute.begin(); for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { if( (*ii).sName == sName ) { return (*ii).sType; } } return OUString(); } OUString AttributeListImpl::getValueByName(const OUString& sName) throw (RuntimeException) { ::std::vector::iterator ii = m_pImpl->vecAttribute.begin(); for( ; ii != m_pImpl->vecAttribute.end() ; ++ii ) { if( (*ii).sName == sName ) { return (*ii).sValue; } } return OUString(); } AttributeListImpl::AttributeListImpl() { m_pImpl = new AttributeListImpl_impl; } AttributeListImpl::~AttributeListImpl() { delete m_pImpl; } void AttributeListImpl::addAttribute( const OUString &sName , const OUString &sType , const OUString &sValue ) { m_pImpl->vecAttribute.push_back( TagAttribute( sName , sType , sValue ) ); } } // anonymous namespace Any SAL_CALL OReadAccelatorDocumentHandler::queryInterface( const Type & rType ) throw( RuntimeException ) { Any a = ::cppu::queryInterface( rType ,(static_cast< XDocumentHandler* >(this))); if ( a.hasValue() ) return a; else return OWeakObject::queryInterface( rType ); } void SAL_CALL OReadAccelatorDocumentHandler::ignorableWhitespace( const OUString& ) throw( SAXException, RuntimeException ) { } void SAL_CALL OReadAccelatorDocumentHandler::processingInstruction( const OUString&, const OUString& ) throw( SAXException, RuntimeException ) { } void SAL_CALL OReadAccelatorDocumentHandler::setDocumentLocator( const Reference< XLocator > &xLocator) throw( SAXException, RuntimeException ) { m_xLocator = xLocator; } ::rtl::OUString OReadAccelatorDocumentHandler::getErrorLineString() { char buffer[32]; if ( m_xLocator.is() ) { return OUString::createFromAscii( buffer ); } else return OUString(); } void SAL_CALL OReadAccelatorDocumentHandler::startDocument(void) throw ( SAXException, RuntimeException ) { } void SAL_CALL OReadAccelatorDocumentHandler::endDocument(void) throw( SAXException, RuntimeException ) { if ( m_nElementDepth > 0 ) { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "A closing element is missing!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } } void SAL_CALL OReadAccelatorDocumentHandler::startElement( const OUString& aElementName, const Reference< XAttributeList > &xAttrList ) throw( SAXException, RuntimeException ) { m_nElementDepth++; if ( aElementName == ELEMENT_ACCELERATORLIST ) { // acceleratorlist if ( m_bAcceleratorMode ) { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "Accelerator list used twice!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } else m_bAcceleratorMode = sal_True; } else if ( aElementName == ELEMENT_ACCELERATORITEM ) { // accelerator item if ( !m_bAcceleratorMode ) { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "Accelerator list element has to be used before!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } else { // read accelerator item m_bItemCloseExpected = sal_True; SvtAcceleratorConfigItem aItem; // read attributes for accelerator for ( sal_Int16 i=0; i< xAttrList->getLength(); i++ ) { OUString aName = xAttrList->getNameByIndex( i ); OUString aValue = xAttrList->getValueByIndex( i ); if ( aName == ATTRIBUTE_URL ) aItem.aCommand = aValue; else if ( aName == ATTRIBUTE_MODIFIER ) aItem.nModifier = (sal_uInt16)aValue.toInt32(); else if ( aName == ATTRIBUTE_KEYCODE ) aItem.nCode = (sal_uInt16)aValue.toInt32(); } m_aReadAcceleratorList.push_back( aItem ); } } else { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown element found!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } } void SAL_CALL OReadAccelatorDocumentHandler::characters(const rtl::OUString&) throw( SAXException, RuntimeException ) { } void SAL_CALL OReadAccelatorDocumentHandler::endElement( const OUString& aName ) throw( SAXException, RuntimeException ) { m_nElementDepth--; if ( aName == ELEMENT_ACCELERATORLIST ) { // acceleratorlist if ( !m_bAcceleratorMode ) { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "Accelerator list used twice!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } } else if ( aName == ELEMENT_ACCELERATORITEM ) { if ( !m_bItemCloseExpected ) { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "Closing accelerator item element expected!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } } else { OUString aErrorMessage = getErrorLineString(); aErrorMessage += OUString( RTL_CONSTASCII_USTRINGPARAM( "Unknown closing element found!" )); throw SAXException( aErrorMessage, Reference< XInterface >(), Any() ); } } // ------------------------------------------------------------------ OWriteAccelatorDocumentHandler::OWriteAccelatorDocumentHandler( const SvtAcceleratorItemList& aWriteAcceleratorList, Reference< XDocumentHandler > xDocumentHandler ) : m_xWriteDocumentHandler( xDocumentHandler ), m_aWriteAcceleratorList( aWriteAcceleratorList ) { m_aAttributeType = OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_TYPE_CDATA )); } OWriteAccelatorDocumentHandler::~OWriteAccelatorDocumentHandler() { } void OWriteAccelatorDocumentHandler::WriteAcceleratorDocument() throw ( SAXException, RuntimeException ) { AttributeListImpl* pList = new AttributeListImpl; Reference< XAttributeList > rList( (XAttributeList *)pList , UNO_QUERY ); m_xWriteDocumentHandler->startDocument(); m_xWriteDocumentHandler->startElement( OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_ACCELERATORLIST )), rList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); std::list< SvtAcceleratorConfigItem>::const_iterator p; for ( p = m_aWriteAcceleratorList.begin(); p != m_aWriteAcceleratorList.end(); ++p ) WriteAcceleratorItem( *p ); m_xWriteDocumentHandler->endElement( OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_ACCELERATORLIST )) ); m_xWriteDocumentHandler->endDocument(); } void OWriteAccelatorDocumentHandler::WriteAcceleratorItem( const SvtAcceleratorConfigItem& aAcceleratorItem ) throw( SAXException, RuntimeException ) { AttributeListImpl* pAcceleratorAttributes = new AttributeListImpl; Reference< XAttributeList > xAcceleratorAttrList( (XAttributeList *)pAcceleratorAttributes , UNO_QUERY ); // set attributes pAcceleratorAttributes->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_KEYCODE )), m_aAttributeType, OUString::valueOf( aAcceleratorItem.nCode )); pAcceleratorAttributes->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_MODIFIER )), m_aAttributeType, OUString::valueOf( aAcceleratorItem.nModifier )); pAcceleratorAttributes->addAttribute( OUString( RTL_CONSTASCII_USTRINGPARAM( ATTRIBUTE_URL )), m_aAttributeType, aAcceleratorItem.aCommand ); // write start element m_xWriteDocumentHandler->startElement( OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_ACCELERATORITEM )), xAcceleratorAttrList ); m_xWriteDocumentHandler->ignorableWhitespace( OUString() ); m_xWriteDocumentHandler->endElement( OUString( RTL_CONSTASCII_USTRINGPARAM( ELEMENT_ACCELERATORITEM )) ); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ _contract138d LibreOffice 核心代码仓库文档基金会
summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-06-26loplugin:useuniqueptr in ScConsolidateParamNoel Grandin
Change-Id: I451315b844e759db3084220a1c889f47775189e3 Reviewed-on: https://gerrit.libreoffice.org/56331 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-06-18use std::atomic rather than OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIERLuboš Luňák
Sources such as http://preshing.com/20130930/double-checked-locking-is-fixed-in-cpp11/ or https://en.wikipedia.org/wiki/Double-checked_locking suggest that it wasn't possible to reliably do a portable double-checked initialization before C++11. It may be true that for all platforms we support those memory barriers are in fact not needed (which seems to be the assumption behind OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER being empty), and looking at the generated assembly here on x86-64 seems to confirm that, but in the worst case then this is a more chatty and standard way of writing a no-op. I don't want to use threadsafe statics or std::call_once() because ScGlobal::Clear() does cleanup, which would be non-trivial to do with these, and also some functions may not necessarily always force creation of the singleton when touching the pointer, so it can't be easily hidden behind a single function call. The need to explicitly use load() with delete (thus preventing DELETEZ) looks like a Clang bug to me. Change-Id: Id3b0ef4b273ed25a5c154f90cde090ea1f9674fb Reviewed-on: https://gerrit.libreoffice.org/55851 Tested-by: Jenkins Reviewed-by: Michael Meeks <michael.meeks@collabora.com>
2018-05-31move mbThreadedGroupCalcInProgress from ScDocument to ScGlobalLuboš Luňák
Some code, such as statics in ScGlobal, cannot(?) easily access ScDocument. Moreover whether Calc is currently performing threaded calculations is not really a state of a document but of Calc itself. Still keep the state accessible via ScDocument for the pipe-dream future where it possibly really will be a state of the document. Change-Id: I2b112221e7fa1b2b4469cfd289fc201025585a5f Reviewed-on: https://gerrit.libreoffice.org/54796 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Tested-by: Michael Meeks <michael.meeks@collabora.com>
2018-05-25tdf#42949 Fix IWYU warnings in sc/inc/[gh]*Gabor Kelemen
Found with bin/find-unneeded-includes Simple removal proposals are dealt with here and a bit of fallout management Change-Id: Ia6f8d4ca46d7b218f5827052ced5641367bd4478 Reviewed-on: https://gerrit.libreoffice.org/54683 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Miklos Vajna <vmiklos@collabora.co.uk>
2018-05-14Drop module-specific defines of DELETEZGabor Kelemen
The one in tools/solar.h is the only one needed. Change-Id: I7a4e041694fb61329d16f300be4f986eb8d4ec48 Reviewed-on: https://gerrit.libreoffice.org/54202 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-05-13Drop newly unused ScGlobal::GetRscStringGabor Kelemen
Change-Id: I744b069542007d7ed965ef229a263c09a27181ce Reviewed-on: https://gerrit.libreoffice.org/54187 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Julien Nabet <serval2412@yahoo.fr>
2018-04-19drop IS_SET macroNoel Grandin
Change-Id: I876462e3f436b1540bb1a7ef92f184fa1c0be0e8 Reviewed-on: https://gerrit.libreoffice.org/53102 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-04-18convert DelCellCmd to scoped enumNoel Grandin
Change-Id: I4766fc874026f218b33e66944b98562d1ec614d3 Reviewed-on: https://gerrit.libreoffice.org/53088 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2018-03-26tdf#116241 Customizing value highlighting colorsSzymon Kłos
Available in: Tools->Options->Application colors Change-Id: I6e4f7a0dcad9a6ee222275019596853f0cbd3ab0 Reviewed-on: https://gerrit.libreoffice.org/51791 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Szymon Kłos <szymon.klos@collabora.com>
2018-03-06tdf#114552 Add a third anchor type for calc graphicsSamuel Mehrbrodt
This allows to have two cell anchored types: * Only cell anchored (moves with the cell when sorting etc) * Cell anchored, also resizes with the cell Beforehand, all cell anchored images would resize with the cell, which was often not what users expected. The new default (when inserting images) is now that inserted images are only anchored to the cell, but don't resize with the cell. This makes use of the ODF elements table:end-cell-address, table:end-x, table:end-y. When images should resize with the cell, the end address is written (it has always been written earlier, so documents would still import correctly). If not, they are omitted. Also implements xlsx import & export Change-Id: I5f96242f88943ed77a0fd12b7f39b444e1380df7 Reviewed-on: https://gerrit.libreoffice.org/49490 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Samuel Mehrbrodt <Samuel.Mehrbrodt@cib.de>
2018-02-16Consolidate the dreaded "Text - txt - csv (StarCalc)" filter nameEike Rathke
... into one define SC_TEXT_CSV_FILTER_NAME. This might prevent typos and doesn't look as ugly. Change-Id: If954852e5e6673331b29c4994f9d97c77b6564a6
2018-01-19inline some definesNoel Grandin
which don't add any value anymore Change-Id: I45977d972d4d02926630b749d3ec736416138cf5
2017-12-19wrap scoped enum around css::util::NumberFormatNoel Grandin
Change-Id: Icab5ded8bccdb95f79b3fa35ea164f47919c68fa Reviewed-on: https://gerrit.libreoffice.org/46339 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Eike Rathke <erack@redhat.com>
2017-11-24consistently use sal_uInt32 for number formats in scNoel Grandin
instead of a mix of short/sal_uLong/sal_uInt32 Change-Id: Ie5bd26e1a6f716c0c4e174a6d560827084b3f421 Reviewed-on: https://gerrit.libreoffice.org/45159 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-08-22loplugin:constparam in sc part1Noel Grandin
Change-Id: I82fba7ebb3b4f018721642c96bbfa615c6a382c3 Reviewed-on: https://gerrit.libreoffice.org/41419 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
2017-07-31make IntlWrapper arg to GetPresentation non-implicit and non-optionalCaolán McNamara
which requires explicitly adding null in 1) SdrItemBrowserControl::SetAttributes(const SfxItemSet* pSet, const SfxItemSet* p2ndSet) where SdrItemBrowserControl is only used by SdrItemBrowser and the only use of that is within DBG_UTIL in SdrPaintView 2) SwCursorShell::GetContentAtPos( const Point& rPt, within a #ifdef DBG_UTIL block in 3) SvxSearchDialog::BuildAttrText_Impl( OUString& rStr, bool bSrchFlag ) const where the other branch uses SvxResId 4) SfxPoolItem::dumpAsXml(xmlTextWriterPtr pWriter) const 5) XFillStyleItem::dumpAsXml(xmlTextWriterPtr pWriter) const looks very much like all uses (outside the dumpers) are intended to be in the ui locale results in that INetContentTypes::GetPresentation always called with UI Locale Change-Id: I5a110c107838b4db3c355476426d6532f2b6ce52 Reviewed-on: https://gerrit.libreoffice.org/40538 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
2017-07-27add test for update address code, related tdf#107289Markus Mohrhard
Change-Id: I955cf49fe5fa47fb38d2c8dacf4aadc8e3f7d651 Reviewed-on: https://gerrit.libreoffice.org/39317 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
2017-07-21migrate to boost::gettextCaolán McNamara
* all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a