23 #include <oox/token/namespaces.hxx>
24 #include <oox/token/tokens.hxx>
25 #include <rtl/ustrbuf.hxx>
27 #include <osl/diagnose.h>
28 #include <com/sun/star/frame/XModel.hpp>
29 #include <com/sun/star/lang/XServiceInfo.hpp>
50 mbEnableTrimSpace( bEnableTrimSpace ),
57 mxContextStack( rParent.mxContextStack ),
58 mnRootStackSize( rParent.mxContextStack->
size() ),
59 mbEnableTrimSpace( rParent.mbEnableTrimSpace ),
76 [](
const ElementInfo& rItem) {
return getNamespace(rItem.mnElement) != NMSP_mce; });
86 return (
mxContextStack->size() ==
static_cast< size_t >( nCountBack )) ?
96 sal_Int32 nElement,
const Reference< XFastAttributeList >& rxAttribs )
120 OSL_ENSURE(
getCurrentElementWithMce() == nElement,
"ContextHandler2Helper::implEndElement - context stack broken" );
161 OSL_ENSURE( !
mxContextStack->empty(),
"ContextHandler2Helper::popElementInfo - context stack broken" );
168 OSL_ENSURE( !
mxContextStack->empty(),
"ContextHandler2Helper::processCollectedChars - no context info" );
174 OUString aChars = rInfo.
maChars.makeStringAndClear();
176 aChars = aChars.trim();
177 if( !aChars.isEmpty() )
195 sal_Int32 nElement,
const Reference< XFastAttributeList >& rxAttribs )
197 if( getNamespace( nElement ) == NMSP_mce )
208 sal_Int32 nElement,
const Reference< XFastAttributeList >& rxAttribs )
227 case MCE_TOKEN( AlternateContent ):
231 case MCE_TOKEN( Choice ):
236 OUString aRequires = rAttribs.
getString( XML_Requires,
"none" );
242 std::vector<OUString> aSupportedNS =
252 if (xModel.is() && xModel->supportsService(
"com.sun.star.sheet.SpreadsheetDocument"))
255 auto it = std::find(aSupportedNS.begin(), aSupportedNS.end(),
"a14");
256 if (it != aSupportedNS.end())
258 aSupportedNS.erase(it);
262 if (std::find(aSupportedNS.begin(), aSupportedNS.end(), aRequires) != aSupportedNS.end())
269 case MCE_TOKEN( Fallback ):
275 OUString str = rAttribs.
getString( MCE_TOKEN( Ignorable ), OUString() );
Information about a processed element.
virtual void onEndElement() override
Will be called when the current element is about to be left.
void processCollectedChars()
void implEndRecord(sal_Int32 nRecId)
Must be called from endRecord() in derived classes.
css::uno::Reference< css::xml::sax::XFastContextHandler > implCreateChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
Must be called from createFastChildContext() in derived classes.
virtual void onStartElement(const AttributeList &rAttribs) override
Will be called when a new element has been started.
std::vector< ElementInfo > ContextStack
void implStartElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs)
Must be called from startFastElement() in derived classes.
bool mbTrimSpaces
The element identifier.
MCE_STATE getMCEState() const
OptValue< OUString > getString(sal_Int32 nAttrToken) const
Returns the string value of the specified attribute.
std::shared_ptr< T > make_shared(Args &&...args)
sal_Int32 getParentElement(sal_Int32 nCountBack=1) const
Returns the identifier of the specified parent element.
bool prepareMceContext(sal_Int32 nElement, const AttributeList &rAttribs)
size_t mnRootStackSize
Stack size on construction time.
sal_Int32 getCurrentElementWithMce() const
Returns the identifier of the currently processed element - Including MCE root elements.
virtual ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
Will be called to create a context handler for the passed record.
bool mbEnableTrimSpace
True = trim whitespace in characters().
virtual ~ContextHandler2Helper()
virtual void SAL_CALL endFastElement(sal_Int32 nElement) final override
virtual css::uno::Reference< css::xml::sax::XFastContextHandler > SAL_CALL createFastChildContext(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs) final override
virtual void onEndRecord()=0
Will be called when the current record block is about to be left.
virtual void onEndElement()=0
Will be called when the current element is about to be left.
virtual void SAL_CALL characters(const OUString &rChars) final override
virtual void onCharacters(const OUString &rChars) override
Will be called before a new child element starts, or if the current element is about to be left...
void implStartRecord(sal_Int32 nRecId, SequenceInputStream &rStrm)
Must be called from startRecord() in derived classes.
ContextHandler2Helper(bool bEnableTrimSpace, XmlFilterBase &rFilter)
XmlFilterBase & getDocFilter() const
virtual ~ContextHandler2() override
virtual ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs) override
Will be called to create a context handler for the passed element.
sal_Int32 mnElement
Collected element characters.
ContextStackRef mxContextStack
Stack of all processed elements.
sal_Int32 getCurrentElement() const
Returns the identifier of the currently processed element.
constexpr std::enable_if_t< std::is_signed_v< T >, std::make_unsigned_t< T > > make_unsigned(T value)
virtual void SAL_CALL startFastElement(sal_Int32 nElement, const css::uno::Reference< css::xml::sax::XFastAttributeList > &rxAttribs) final override
virtual void onEndRecord() override
Will be called when the current record block is about to be left.
virtual ContextHandlerRef onCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm)=0
Will be called to create a context handler for the passed record.
virtual void onStartElement(const AttributeList &rAttribs)=0
Will be called when a new element has been started.
Provides access to attribute values of an element.
bool isRootElement() const
Returns true, if the element currently processed is the root element of the context or fragment handl...
ElementInfo()
True = trims leading/trailing spaces from text data.
bool isMCEStateEmpty() const
virtual void startRecord(sal_Int32 nRecId, SequenceInputStream &rStrm) override
void implEndElement(sal_Int32 nElement)
Must be called from endFastElement() in derived classes.
virtual void endRecord(sal_Int32 nRecId) override
virtual ContextHandlerRef onCreateContext(sal_Int32 nElement, const AttributeList &rAttribs)=0
Will be called to create a context handler for the passed element.
void implCharacters(std::u16string_view rChars)
Must be called from characters() in derived classes.
ContextHandler2(ContextHandler2Helper const &rParent)
void setMCEState(MCE_STATE aState)
virtual void onStartRecord(SequenceInputStream &rStrm)=0
Will be called when a new record block in a binary stream has been started.
virtual void onCharacters(const OUString &rChars)=0
Will be called before a new child element starts, or if the current element is about to be left...
virtual ContextHandlerRef createRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm) override
const sal_Int32 XML_ROOT_CONTEXT
void addMCEState(MCE_STATE aState)
ContextHandlerRef implCreateRecordContext(sal_Int32 nRecId, SequenceInputStream &rStrm)
Must be called from createRecordContext() in derived classes.
Reference< XModel > xModel
const PowerPointImport & mrFilter
virtual void onStartRecord(SequenceInputStream &rStrm) override
Will be called when a new record block in a binary stream has been started.
Helper class that provides a context stack.
OptValue< sal_Int32 > getToken(sal_Int32 nAttrToken) const
Returns the token identifier of the value of the specified attribute.
bool m_bDetectedRangeSegmentation false
ElementInfo & pushElementInfo(sal_Int32 nElement)