LibreOffice Module sc (master)  1
afmtuno.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
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/.
8  *
9  * This file incorporates work covered by the following license notice:
10  *
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 .
18  */
19 
20 #pragma once
21 
22 #include <svl/itemprop.hxx>
23 #include <com/sun/star/lang/XServiceInfo.hpp>
24 #include <com/sun/star/container/XIndexAccess.hpp>
25 #include <com/sun/star/container/XEnumerationAccess.hpp>
26 #include <com/sun/star/container/XNameContainer.hpp>
27 #include <com/sun/star/container/XNamed.hpp>
28 #include <com/sun/star/beans/XPropertySet.hpp>
29 #include <com/sun/star/lang/XUnoTunnel.hpp>
31 #include <cppuhelper/implbase.hxx>
32 
33 #include <climits>
34 
36 class ScAutoFormatObj;
37 
38 #define SC_AFMTOBJ_INVALID USHRT_MAX
39 
40 class ScAutoFormatsObj final : public ::cppu::WeakImplHelper<
41  css::container::XNameContainer,
42  css::container::XEnumerationAccess,
43  css::container::XIndexAccess,
44  css::lang::XServiceInfo >
45 {
46 private:
49 
50 public:
52  virtual ~ScAutoFormatsObj() override;
53 
54  // XNameContainer
55  virtual void SAL_CALL insertByName( const OUString& aName,
56  const css::uno::Any& aElement ) override;
57  virtual void SAL_CALL removeByName( const OUString& Name ) override;
58 
59  // XNameReplace
60  virtual void SAL_CALL replaceByName( const OUString& aName,
61  const css::uno::Any& aElement ) override;
62 
63  // XNameAccess
64  virtual css::uno::Any SAL_CALL getByName( const OUString& aName ) override;
65  virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override;
66  virtual sal_Bool SAL_CALL hasByName( const OUString& aName ) override;
67 
68  // XElementAccess
69  virtual css::uno::Type SAL_CALL getElementType() override;
70  virtual sal_Bool SAL_CALL hasElements() override;
71 
72  // XEnumerationAccess
73  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
74  createEnumeration() override;
75 
76  // XIndexAccess
77  virtual sal_Int32 SAL_CALL getCount() override;
78  virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
79 
80  // XServiceInfo
81  virtual OUString SAL_CALL getImplementationName() override;
82  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
83  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
84 };
85 
86 class ScAutoFormatObj final : public ::cppu::WeakImplHelper<
87  css::container::XIndexAccess,
88  css::container::XEnumerationAccess,
89  css::container::XNamed,
90  css::beans::XPropertySet,
91  css::lang::XUnoTunnel,
92  css::lang::XServiceInfo >
93 {
94 private:
96  sal_uInt16 nFormatIndex;
97 
99 
100 public:
101  ScAutoFormatObj(sal_uInt16 nIndex);
102  virtual ~ScAutoFormatObj() override;
103 
104  // called via getImplementation:
105  bool IsInserted() const { return nFormatIndex != SC_AFMTOBJ_INVALID; }
106  void InitFormat( sal_uInt16 nNewIndex );
107 
108  // XIndexAccess
109  virtual sal_Int32 SAL_CALL getCount() override;
110  virtual css::uno::Any SAL_CALL getByIndex( sal_Int32 Index ) override;
111 
112  // XElementAccess
113  virtual css::uno::Type SAL_CALL getElementType() override;
114  virtual sal_Bool SAL_CALL hasElements() override;
115 
116  // XEnumerationAccess
117  virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL
118  createEnumeration() override;
119 
120  // XNamed
121  virtual OUString SAL_CALL getName() override;
122  virtual void SAL_CALL setName( const OUString& aName ) override;
123 
124  // XPropertySet
125  virtual css::uno::Reference< css::beans::XPropertySetInfo >
126  SAL_CALL getPropertySetInfo() override;
127  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
128  const css::uno::Any& aValue ) override;
129  virtual css::uno::Any SAL_CALL getPropertyValue(
130  const OUString& PropertyName ) override;
131  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
132  const css::uno::Reference<
133  css::beans::XPropertyChangeListener >& xListener ) override;
134  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
135  const css::uno::Reference<
136  css::beans::XPropertyChangeListener >& aListener ) override;
137  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
138  const css::uno::Reference<
139  css::beans::XVetoableChangeListener >& aListener ) override;
140  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
141  const css::uno::Reference<
142  css::beans::XVetoableChangeListener >& aListener ) override;
143 
144  // XServiceInfo
145  virtual OUString SAL_CALL getImplementationName() override;
146  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
147  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
148 
149  // XUnoTunnel
151 };
152 
153 class ScAutoFormatFieldObj final : public ::cppu::WeakImplHelper<
154  css::beans::XPropertySet,
155  css::lang::XServiceInfo >
156 {
157 private:
159  sal_uInt16 nFormatIndex;
160  sal_uInt16 nFieldIndex;
161 
162 public:
163  ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField);
164  virtual ~ScAutoFormatFieldObj() override;
165 
166  // XPropertySet
167  virtual css::uno::Reference< css::beans::XPropertySetInfo >
168  SAL_CALL getPropertySetInfo() override;
169  virtual void SAL_CALL setPropertyValue( const OUString& aPropertyName,
170  const css::uno::Any& aValue ) override;
171  virtual css::uno::Any SAL_CALL getPropertyValue(
172  const OUString& PropertyName ) override;
173  virtual void SAL_CALL addPropertyChangeListener( const OUString& aPropertyName,
174  const css::uno::Reference< css::beans::XPropertyChangeListener >& xListener ) override;
175  virtual void SAL_CALL removePropertyChangeListener( const OUString& aPropertyName,
176  const css::uno::Reference< css::beans::XPropertyChangeListener >& aListener ) override;
177  virtual void SAL_CALL addVetoableChangeListener( const OUString& PropertyName,
178  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
179  virtual void SAL_CALL removeVetoableChangeListener( const OUString& PropertyName,
180  const css::uno::Reference< css::beans::XVetoableChangeListener >& aListener ) override;
181 
182  // XServiceInfo
183  virtual OUString SAL_CALL getImplementationName() override;
184  virtual sal_Bool SAL_CALL supportsService( const OUString& ServiceName ) override;
185  virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override;
186 };
187 
188 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
sal_Int32 nIndex
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: afmtuno.cxx:277
ScAutoFormatObj(sal_uInt16 nIndex)
Definition: afmtuno.cxx:332
virtual sal_Bool SAL_CALL hasElements() override
Definition: afmtuno.cxx:410
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: afmtuno.cxx:506
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
OUString Name
virtual sal_Int32 SAL_CALL getCount() override
Definition: afmtuno.cxx:383
#define UNO3_GETIMPLEMENTATION_DECL(classname)
virtual css::uno::Any SAL_CALL getPropertyValue(const OUString &PropertyName) override
Definition: afmtuno.cxx:665
virtual OUString SAL_CALL getImplementationName() override
sal_uInt16 nFormatIndex
Definition: afmtuno.hxx:159
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: afmtuno.cxx:557
sal_uInt16 nFieldIndex
Definition: afmtuno.hxx:160
virtual css::uno::Sequence< OUString > SAL_CALL getElementNames() override
Definition: afmtuno.cxx:309
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: afmtuno.cxx:564
SfxItemPropertySet aPropSet
Definition: afmtuno.hxx:95
virtual css::uno::Reference< css::beans::XPropertySetInfo > SAL_CALL getPropertySetInfo() override
Definition: afmtuno.cxx:468
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual void SAL_CALL setPropertyValue(const OUString &aPropertyName, const css::uno::Any &aValue) override
Definition: afmtuno.cxx:475
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual ~ScAutoFormatsObj() override
Definition: afmtuno.cxx:154
unsigned char sal_Bool
bool IsInserted() const
Definition: afmtuno.hxx:105
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
virtual ~ScAutoFormatObj() override
Definition: afmtuno.cxx:338
virtual ~ScAutoFormatFieldObj() override
Definition: afmtuno.cxx:551
virtual sal_Int32 SAL_CALL getCount() override
Definition: afmtuno.cxx:271
virtual void SAL_CALL removeByName(const OUString &Name) override
Definition: afmtuno.cxx:244
virtual OUString SAL_CALL getImplementationName() override
virtual css::uno::Type SAL_CALL getElementType() override
Definition: afmtuno.cxx:286
virtual void SAL_CALL addPropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &xListener) override
virtual void SAL_CALL setName(const OUString &aName) override
Definition: afmtuno.cxx:428
virtual css::uno::Sequence< OUString > SAL_CALL getSupportedServiceNames() override
virtual void SAL_CALL addVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
void InitFormat(sal_uInt16 nNewIndex)
Definition: afmtuno.cxx:353
virtual css::uno::Any SAL_CALL getByIndex(sal_Int32 Index) override
Definition: afmtuno.cxx:392
#define SC_AFMTOBJ_INVALID
Definition: afmtuno.hxx:38
ScAutoFormatFieldObj(sal_uInt16 nFormat, sal_uInt16 nField)
Definition: afmtuno.cxx:544
SfxItemPropertySet aPropSet
Definition: afmtuno.hxx:158
OUString aName
virtual css::uno::Type SAL_CALL getElementType() override
Definition: afmtuno.cxx:404
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual void SAL_CALL removePropertyChangeListener(const OUString &aPropertyName, const css::uno::Reference< css::beans::XPropertyChangeListener > &aListener) override
sal_uInt16 nFormatIndex
Definition: afmtuno.hxx:96
virtual OUString SAL_CALL getName() override
Definition: afmtuno.cxx:418
rtl::Reference< ScAutoFormatFieldObj > GetObjectByIndex_Impl(sal_uInt16 nIndex)
Definition: afmtuno.cxx:365
virtual sal_Bool SAL_CALL hasByName(const OUString &aName) override
Definition: afmtuno.cxx:324
virtual void SAL_CALL replaceByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: afmtuno.cxx:236
virtual void SAL_CALL insertByName(const OUString &aName, const css::uno::Any &aElement) override
Definition: afmtuno.cxx:187
virtual css::uno::Any SAL_CALL getByName(const OUString &aName) override
Definition: afmtuno.cxx:300
virtual void SAL_CALL removeVetoableChangeListener(const OUString &PropertyName, const css::uno::Reference< css::beans::XVetoableChangeListener > &aListener) override
virtual sal_Bool SAL_CALL supportsService(const OUString &ServiceName) override
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: afmtuno.cxx:375
virtual OUString SAL_CALL getImplementationName() override
virtual sal_Bool SAL_CALL hasElements() override
Definition: afmtuno.cxx:292
virtual css::uno::Reference< css::container::XEnumeration > SAL_CALL createEnumeration() override
Definition: afmtuno.cxx:263
static rtl::Reference< ScAutoFormatObj > GetObjectByName_Impl(std::u16string_view aName)
Definition: afmtuno.cxx:176
struct _ADOIndex Index
static rtl::Reference< ScAutoFormatObj > GetObjectByIndex_Impl(sal_uInt16 nIndex)
Definition: afmtuno.cxx:168