LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / forms / source / component / FormattedFieldWrapper.hxx
blobb34db41485313ccf20908d919d1f824e7a720a55
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 #pragma once
22 #include <comphelper/uno3.hxx>
23 #include <cppuhelper/implbase3.hxx>
24 #include <com/sun/star/io/XPersistObject.hpp>
25 #include <com/sun/star/lang/XServiceInfo.hpp>
26 #include <com/sun/star/util/XCloneable.hpp>
27 #include <com/sun/star/uno/XComponentContext.hpp>
28 #include <rtl/ref.hxx>
30 namespace frm
33 class OEditModel;
35 //= OFormattedFieldWrapper
37 typedef ::cppu::WeakAggImplHelper3 < css::io::XPersistObject
38 , css::lang::XServiceInfo
39 , css::util::XCloneable
40 > OFormattedFieldWrapper_Base;
42 class OFormattedFieldWrapper final : public OFormattedFieldWrapper_Base
44 css::uno::Reference< css::uno::XComponentContext> m_xContext;
46 css::uno::Reference< css::uno::XAggregation> m_xAggregate;
48 rtl::Reference< OEditModel > m_pEditPart;
49 // if we act as formatted this is used to write the EditModel part
50 css::uno::Reference< css::io::XPersistObject> m_xFormattedPart;
52 OFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory);
54 virtual ~OFormattedFieldWrapper() override;
56 public:
57 // if we act as formatted, this is the PersistObject interface of our aggregate, used
58 // to read and write the FormattedModel part
59 // if bActAsFormatted is false, the state is undetermined until somebody calls
60 // ::read or does anything which requires a living aggregate
61 static css::uno::Reference<css::uno::XInterface> createFormattedFieldWrapper(const css::uno::Reference< css::uno::XComponentContext>& _rxFactory, bool bActAsFormatted);
63 // UNO
64 DECLARE_UNO3_AGG_DEFAULTS(OFormattedFieldWrapper, OWeakAggObject)
65 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
67 // XServiceInfo
68 virtual OUString SAL_CALL getImplementationName( ) override;
69 virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
70 virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames( ) override;
72 // XPersistObject
73 virtual OUString SAL_CALL getServiceName() override;
74 virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override;
75 virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override;
77 // XCloneable
78 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
80 private:
81 /// ensure we're in a defined state, which means a FormattedModel _OR_ an EditModel
82 void ensureAggregate();
87 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */