LanguageTool: don't crash if REST protocol isn't set
[LibreOffice.git] / forms / source / component / FormattedField.hxx
blobc9d0f1c1705e63ece32832481834584269821cc6
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 "EditBase.hxx"
23 #include <tools/link.hxx>
24 #include <cppuhelper/implbase1.hxx>
25 #include "errorbroadcaster.hxx"
27 #include <com/sun/star/util/XNumberFormatsSupplier.hpp>
29 struct ImplSVEvent;
31 namespace frm
33 class OFormattedModel final
34 :public OEditBaseModel
35 ,public OErrorBroadcaster
37 // the original, in case I faked the format properties of my aggregated model,
38 // i.e. I just passed on the attributes of the field to which I am bound
39 // (only valid if loaded)
41 css::uno::Reference< css::util::XNumberFormatsSupplier> m_xOriginalFormatter;
42 css::util::Date m_aNullDate;
43 css::uno::Any m_aSaveValue;
45 sal_Int16 m_nKeyType;
46 bool m_bOriginalNumeric : 1,
47 m_bNumeric : 1; // analogous for the TreatAsNumeric-property
49 css::uno::Reference< css::util::XNumberFormatsSupplier> calcDefaultFormatsSupplier() const;
50 css::uno::Reference< css::util::XNumberFormatsSupplier> calcFormFormatsSupplier() const;
51 css::uno::Reference< css::util::XNumberFormatsSupplier> calcFormatsSupplier() const;
53 OFormattedModel(
54 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
56 OFormattedModel(
57 const OFormattedModel* _pOriginal,
58 const css::uno::Reference< css::uno::XComponentContext>& _rxFactory
60 virtual ~OFormattedModel() override;
62 friend class OFormattedFieldWrapper;
64 public:
65 // XInterface
66 DECLARE_UNO3_AGG_DEFAULTS( OFormattedModel, OEditBaseModel )
68 // XTypeProvider
69 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
71 // XAggregation
72 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
74 // OComponentHelper
75 virtual void SAL_CALL disposing() override;
77 // XServiceInfo
78 OUString SAL_CALL getImplementationName() override
79 { return "com.sun.star.form.OFormattedModel"; }
81 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
83 // XPersistObject
84 virtual void SAL_CALL write(const css::uno::Reference< css::io::XObjectOutputStream>& _rxOutStream) override;
85 virtual void SAL_CALL read(const css::uno::Reference< css::io::XObjectInputStream>& _rxInStream) override;
86 virtual OUString SAL_CALL getServiceName() override;
88 // XLoadListener
89 virtual void SAL_CALL loaded(const css::lang::EventObject& rEvent) override;
91 // XPropertyState
92 void setPropertyToDefaultByHandle(sal_Int32 nHandle) override;
93 css::uno::Any getPropertyDefaultByHandle(sal_Int32 nHandle) const override;
95 void SAL_CALL setPropertyToDefault(const OUString& aPropertyName) override;
96 css::uno::Any SAL_CALL getPropertyDefault( const OUString& aPropertyName ) override;
98 // OControlModel's property handling
99 virtual void describeFixedProperties(
100 css::uno::Sequence< css::beans::Property >& /* [out] */ _rProps
101 ) const override;
102 virtual void describeAggregateProperties(
103 css::uno::Sequence< css::beans::Property >& /* [out] */ _rAggregateProps
104 ) const override;
106 // XPropertyChangeListener
107 virtual void _propertyChanged(const css::beans::PropertyChangeEvent& evt) override;
109 // prevent method hiding
110 using OEditBaseModel::disposing;
111 using OEditBaseModel::getFastPropertyValue;
113 virtual sal_uInt16 getPersistenceFlags() const override;
114 // as we have an own version handling for persistence
116 // OBoundControlModel overridables
117 virtual css::uno::Any
118 translateDbColumnToControlValue( ) override;
119 virtual bool commitControlValueToDbColumn( bool _bPostReset ) override;
121 virtual css::uno::Sequence< css::uno::Type >
122 getSupportedBindingTypes() override;
123 virtual css::uno::Any
124 translateExternalValueToControlValue( const css::uno::Any& _rExternalValue ) const override;
125 virtual css::uno::Any
126 translateControlValueToExternalValue( ) const override;
127 virtual void onConnectedExternalValue( ) override;
129 virtual css::uno::Any
130 getDefaultForReset() const override;
131 virtual void resetNoBroadcast() override;
133 virtual void onConnectedDbColumn( const css::uno::Reference< css::uno::XInterface >& _rxForm ) override;
134 virtual void onDisconnectedDbColumn() override;
136 virtual css::uno::Reference< css::util::XCloneable > SAL_CALL createClone( ) override;
138 void implConstruct();
140 void updateFormatterNullDate();
143 typedef ::cppu::ImplHelper1< css::awt::XKeyListener> OFormattedControl_BASE;
144 class OFormattedControl : public OBoundControl
145 ,public OFormattedControl_BASE
147 ImplSVEvent * m_nKeyEvent;
149 public:
150 explicit OFormattedControl(const css::uno::Reference< css::uno::XComponentContext>& _rxContext);
151 virtual ~OFormattedControl() override;
153 DECLARE_UNO3_AGG_DEFAULTS(OFormattedControl, OBoundControl)
154 virtual css::uno::Any SAL_CALL queryAggregation(const css::uno::Type& _rType) override;
156 virtual css::uno::Sequence< css::uno::Type> _getTypes() override;
158 // css::lang::XServiceInfo
159 OUString SAL_CALL getImplementationName() override
160 { return "com.sun.star.form.OFormattedControl"; }
162 virtual css::uno::Sequence<OUString> SAL_CALL getSupportedServiceNames() override;
164 // css::lang::XEventListener
165 virtual void SAL_CALL disposing(const css::lang::EventObject& _rSource) override;
167 // css::awt::XKeyListener
168 virtual void SAL_CALL keyPressed(const css::awt::KeyEvent& e) override;
169 virtual void SAL_CALL keyReleased(const css::awt::KeyEvent& e) override;
171 // css::awt::XControl
172 using OBoundControl::setDesignMode;
174 // disambiguation
175 using OBoundControl::disposing;
177 private:
178 DECL_LINK( OnKeyPressed, void*, void );
182 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */