Coverage Report

Created: 2026-05-16 09:25

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/oox/source/drawingml/chart/geographyconverter.cxx
Line
Count
Source
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
10
#include <drawingml/chart/geographyconverter.hxx>
11
#include <drawingml/chart/geographymodel.hxx>
12
#include <oox/helper/propertyset.hxx>
13
#include <oox/token/properties.hxx>
14
#include <comphelper/sequence.hxx>
15
16
using namespace ::com::sun::star;
17
18
namespace oox::drawingml::chart
19
{
20
namespace
21
{
22
uno::Sequence<beans::PropertyValue> addressToProps(const GeoAddressModel& rAddr)
23
0
{
24
0
    std::vector<beans::PropertyValue> aVec;
25
0
    if (rAddr.mosAddress1.has_value())
26
0
        aVec.push_back({ u"address1"_ustr, 0, uno::Any(*rAddr.mosAddress1),
27
0
                         beans::PropertyState_DIRECT_VALUE });
28
0
    if (rAddr.mosCountryRegion.has_value())
29
0
        aVec.push_back({ u"countryRegion"_ustr, 0, uno::Any(*rAddr.mosCountryRegion),
30
0
                         beans::PropertyState_DIRECT_VALUE });
31
0
    if (rAddr.mosAdminDistrict1.has_value())
32
0
        aVec.push_back({ u"adminDistrict1"_ustr, 0, uno::Any(*rAddr.mosAdminDistrict1),
33
0
                         beans::PropertyState_DIRECT_VALUE });
34
0
    if (rAddr.mosAdminDistrict2.has_value())
35
0
        aVec.push_back({ u"adminDistrict2"_ustr, 0, uno::Any(*rAddr.mosAdminDistrict2),
36
0
                         beans::PropertyState_DIRECT_VALUE });
37
0
    if (rAddr.mosPostalCode.has_value())
38
0
        aVec.push_back({ u"postalCode"_ustr, 0, uno::Any(*rAddr.mosPostalCode),
39
0
                         beans::PropertyState_DIRECT_VALUE });
40
0
    if (rAddr.mosLocality.has_value())
41
0
        aVec.push_back({ u"locality"_ustr, 0, uno::Any(*rAddr.mosLocality),
42
0
                         beans::PropertyState_DIRECT_VALUE });
43
0
    if (rAddr.mosIsoCountryCode.has_value())
44
0
        aVec.push_back({ u"isoCountryCode"_ustr, 0, uno::Any(*rAddr.mosIsoCountryCode),
45
0
                         beans::PropertyState_DIRECT_VALUE });
46
0
    return comphelper::containerToSequence(aVec);
47
0
}
48
49
GeoAddressModel addressFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
50
0
{
51
0
    GeoAddressModel aAddr;
52
0
    for (const auto& rProp : rProps)
53
0
    {
54
0
        OUString sVal;
55
0
        if (!(rProp.Value >>= sVal))
56
0
            continue;
57
0
        if (rProp.Name == "address1")
58
0
            aAddr.mosAddress1 = sVal;
59
0
        else if (rProp.Name == "countryRegion")
60
0
            aAddr.mosCountryRegion = sVal;
61
0
        else if (rProp.Name == "adminDistrict1")
62
0
            aAddr.mosAdminDistrict1 = sVal;
63
0
        else if (rProp.Name == "adminDistrict2")
64
0
            aAddr.mosAdminDistrict2 = sVal;
65
0
        else if (rProp.Name == "postalCode")
66
0
            aAddr.mosPostalCode = sVal;
67
0
        else if (rProp.Name == "locality")
68
0
            aAddr.mosLocality = sVal;
69
0
        else if (rProp.Name == "isoCountryCode")
70
0
            aAddr.mosIsoCountryCode = sVal;
71
0
    }
72
0
    return aAddr;
73
0
}
74
75
uno::Sequence<beans::PropertyValue> locationToProps(const GeoLocationModel& rLoc)
76
0
{
77
0
    std::vector<beans::PropertyValue> aVec;
78
0
    if (rLoc.mosLatitude.has_value())
79
0
        aVec.push_back({ u"latitude"_ustr, 0, uno::Any(*rLoc.mosLatitude),
80
0
                         beans::PropertyState_DIRECT_VALUE });
81
0
    if (rLoc.mosLongitude.has_value())
82
0
        aVec.push_back({ u"longitude"_ustr, 0, uno::Any(*rLoc.mosLongitude),
83
0
                         beans::PropertyState_DIRECT_VALUE });
84
0
    if (rLoc.mosEntityName.has_value())
85
0
        aVec.push_back({ u"entityName"_ustr, 0, uno::Any(*rLoc.mosEntityName),
86
0
                         beans::PropertyState_DIRECT_VALUE });
87
0
    if (rLoc.mosEntityType.has_value())
88
0
        aVec.push_back({ u"entityType"_ustr, 0, uno::Any(*rLoc.mosEntityType),
89
0
                         beans::PropertyState_DIRECT_VALUE });
90
0
    if (rLoc.mxAddress.has_value())
91
0
        aVec.push_back({ u"address"_ustr, 0, uno::Any(addressToProps(*rLoc.mxAddress)),
92
0
                         beans::PropertyState_DIRECT_VALUE });
93
0
    return comphelper::containerToSequence(aVec);
94
0
}
95
96
GeoLocationModel locationFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
97
0
{
98
0
    GeoLocationModel aLoc;
99
0
    for (const auto& rProp : rProps)
100
0
    {
101
0
        if (rProp.Name == "latitude")
102
0
        {
103
0
            OUString s;
104
0
            if (rProp.Value >>= s)
105
0
                aLoc.mosLatitude = s;
106
0
        }
107
0
        else if (rProp.Name == "longitude")
108
0
        {
109
0
            OUString s;
110
0
            if (rProp.Value >>= s)
111
0
                aLoc.mosLongitude = s;
112
0
        }
113
0
        else if (rProp.Name == "entityName")
114
0
        {
115
0
            OUString s;
116
0
            if (rProp.Value >>= s)
117
0
                aLoc.mosEntityName = s;
118
0
        }
119
0
        else if (rProp.Name == "entityType")
120
0
        {
121
0
            OUString s;
122
0
            if (rProp.Value >>= s)
123
0
                aLoc.mosEntityType = s;
124
0
        }
125
0
        else if (rProp.Name == "address")
126
0
        {
127
0
            uno::Sequence<beans::PropertyValue> aInner;
128
0
            if (rProp.Value >>= aInner)
129
0
                aLoc.mxAddress = addressFromProps(aInner);
130
0
        }
131
0
    }
132
0
    return aLoc;
133
0
}
134
135
uno::Sequence<beans::PropertyValue> locQueryToProps(const GeoLocationQueryModel& rQ)
136
0
{
137
0
    std::vector<beans::PropertyValue> aVec;
138
0
    if (rQ.mosCountryRegion.has_value())
139
0
        aVec.push_back({ u"countryRegion"_ustr, 0, uno::Any(*rQ.mosCountryRegion),
140
0
                         beans::PropertyState_DIRECT_VALUE });
141
0
    if (rQ.mosAdminDistrict1.has_value())
142
0
        aVec.push_back({ u"adminDistrict1"_ustr, 0, uno::Any(*rQ.mosAdminDistrict1),
143
0
                         beans::PropertyState_DIRECT_VALUE });
144
0
    if (rQ.mosAdminDistrict2.has_value())
145
0
        aVec.push_back({ u"adminDistrict2"_ustr, 0, uno::Any(*rQ.mosAdminDistrict2),
146
0
                         beans::PropertyState_DIRECT_VALUE });
147
0
    if (rQ.mosPostalCode.has_value())
148
0
        aVec.push_back({ u"postalCode"_ustr, 0, uno::Any(*rQ.mosPostalCode),
149
0
                         beans::PropertyState_DIRECT_VALUE });
150
0
    if (rQ.mosEntityType.has_value())
151
0
        aVec.push_back({ u"entityType"_ustr, 0, uno::Any(*rQ.mosEntityType),
152
0
                         beans::PropertyState_DIRECT_VALUE });
153
0
    return comphelper::containerToSequence(aVec);
154
0
}
155
156
GeoLocationQueryModel locQueryFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
157
0
{
158
0
    GeoLocationQueryModel aQ;
159
0
    for (const auto& rProp : rProps)
160
0
    {
161
0
        OUString s;
162
0
        if (!(rProp.Value >>= s))
163
0
            continue;
164
0
        if (rProp.Name == "countryRegion")
165
0
            aQ.mosCountryRegion = s;
166
0
        else if (rProp.Name == "adminDistrict1")
167
0
            aQ.mosAdminDistrict1 = s;
168
0
        else if (rProp.Name == "adminDistrict2")
169
0
            aQ.mosAdminDistrict2 = s;
170
0
        else if (rProp.Name == "postalCode")
171
0
            aQ.mosPostalCode = s;
172
0
        else if (rProp.Name == "entityType")
173
0
            aQ.mosEntityType = s;
174
0
    }
175
0
    return aQ;
176
0
}
177
178
uno::Sequence<beans::PropertyValue> locResultToProps(const GeoLocationQueryResultModel& rR)
179
0
{
180
0
    std::vector<beans::PropertyValue> aVec;
181
0
    if (rR.mxQuery.has_value())
182
0
        aVec.push_back({ u"query"_ustr, 0, uno::Any(locQueryToProps(*rR.mxQuery)),
183
0
                         beans::PropertyState_DIRECT_VALUE });
184
0
    std::vector<uno::Sequence<beans::PropertyValue>> aLocs;
185
0
    for (const auto& rLoc : rR.maLocations)
186
0
        aLocs.push_back(locationToProps(rLoc));
187
0
    if (!aLocs.empty())
188
0
        aVec.push_back({ u"locations"_ustr, 0, uno::Any(comphelper::containerToSequence(aLocs)),
189
0
                         beans::PropertyState_DIRECT_VALUE });
190
0
    return comphelper::containerToSequence(aVec);
191
0
}
192
193
GeoLocationQueryResultModel locResultFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
194
0
{
195
0
    GeoLocationQueryResultModel aR;
196
0
    for (const auto& rProp : rProps)
197
0
    {
198
0
        if (rProp.Name == "query")
199
0
        {
200
0
            uno::Sequence<beans::PropertyValue> aInner;
201
0
            if (rProp.Value >>= aInner)
202
0
                aR.mxQuery = locQueryFromProps(aInner);
203
0
        }
204
0
        else if (rProp.Name == "locations")
205
0
        {
206
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
207
0
            if (rProp.Value >>= aArr)
208
0
                for (const auto& rL : aArr)
209
0
                    aR.maLocations.push_back(locationFromProps(rL));
210
0
        }
211
0
    }
212
0
    return aR;
213
0
}
214
215
uno::Sequence<beans::PropertyValue> polygonToProps(const GeoPolygonModel& rP)
216
0
{
217
0
    std::vector<beans::PropertyValue> aVec;
218
0
    if (rP.mosPolygonId.has_value())
219
0
        aVec.push_back({ u"polygonId"_ustr, 0, uno::Any(*rP.mosPolygonId),
220
0
                         beans::PropertyState_DIRECT_VALUE });
221
0
    if (rP.mosNumPoints.has_value())
222
0
        aVec.push_back({ u"numPoints"_ustr, 0, uno::Any(*rP.mosNumPoints),
223
0
                         beans::PropertyState_DIRECT_VALUE });
224
0
    if (rP.mosPcaRings.has_value())
225
0
        aVec.push_back(
226
0
            { u"pcaRings"_ustr, 0, uno::Any(*rP.mosPcaRings), beans::PropertyState_DIRECT_VALUE });
227
0
    return comphelper::containerToSequence(aVec);
228
0
}
229
230
GeoPolygonModel polygonFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
231
0
{
232
0
    GeoPolygonModel aP;
233
0
    for (const auto& rProp : rProps)
234
0
    {
235
0
        OUString s;
236
0
        if (!(rProp.Value >>= s))
237
0
            continue;
238
0
        if (rProp.Name == "polygonId")
239
0
            aP.mosPolygonId = s;
240
0
        else if (rProp.Name == "numPoints")
241
0
            aP.mosNumPoints = s;
242
0
        else if (rProp.Name == "pcaRings")
243
0
            aP.mosPcaRings = s;
244
0
    }
245
0
    return aP;
246
0
}
247
248
uno::Sequence<beans::PropertyValue> geoDataToProps(const GeoDataModel& rD)
249
0
{
250
0
    std::vector<beans::PropertyValue> aVec;
251
0
    if (rD.mosEntityName.has_value())
252
0
        aVec.push_back({ u"entityName"_ustr, 0, uno::Any(*rD.mosEntityName),
253
0
                         beans::PropertyState_DIRECT_VALUE });
254
0
    if (rD.mosEntityId.has_value())
255
0
        aVec.push_back(
256
0
            { u"entityId"_ustr, 0, uno::Any(*rD.mosEntityId), beans::PropertyState_DIRECT_VALUE });
257
0
    if (rD.mosEast.has_value())
258
0
        aVec.push_back(
259
0
            { u"east"_ustr, 0, uno::Any(*rD.mosEast), beans::PropertyState_DIRECT_VALUE });
260
0
    if (rD.mosWest.has_value())
261
0
        aVec.push_back(
262
0
            { u"west"_ustr, 0, uno::Any(*rD.mosWest), beans::PropertyState_DIRECT_VALUE });
263
0
    if (rD.mosNorth.has_value())
264
0
        aVec.push_back(
265
0
            { u"north"_ustr, 0, uno::Any(*rD.mosNorth), beans::PropertyState_DIRECT_VALUE });
266
0
    if (rD.mosSouth.has_value())
267
0
        aVec.push_back(
268
0
            { u"south"_ustr, 0, uno::Any(*rD.mosSouth), beans::PropertyState_DIRECT_VALUE });
269
0
    if (!rD.maPolygons.empty())
270
0
    {
271
0
        std::vector<uno::Sequence<beans::PropertyValue>> aPolys;
272
0
        for (const auto& rP : rD.maPolygons)
273
0
            aPolys.push_back(polygonToProps(rP));
274
0
        aVec.push_back({ u"polygons"_ustr, 0, uno::Any(comphelper::containerToSequence(aPolys)),
275
0
                         beans::PropertyState_DIRECT_VALUE });
276
0
    }
277
0
    if (!rD.maCopyrights.empty())
278
0
    {
279
0
        std::vector<OUString> aCR;
280
0
        for (const auto& rC : rD.maCopyrights)
281
0
            aCR.push_back(rC.msText);
282
0
        aVec.push_back({ u"copyrights"_ustr, 0, uno::Any(comphelper::containerToSequence(aCR)),
283
0
                         beans::PropertyState_DIRECT_VALUE });
284
0
    }
285
0
    return comphelper::containerToSequence(aVec);
286
0
}
287
288
GeoDataModel geoDataFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
289
0
{
290
0
    GeoDataModel aD;
291
0
    for (const auto& rProp : rProps)
292
0
    {
293
0
        if (rProp.Name == "polygons")
294
0
        {
295
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
296
0
            if (rProp.Value >>= aArr)
297
0
                for (const auto& rP : aArr)
298
0
                    aD.maPolygons.push_back(polygonFromProps(rP));
299
0
        }
300
0
        else if (rProp.Name == "copyrights")
301
0
        {
302
0
            uno::Sequence<OUString> aArr;
303
0
            if (rProp.Value >>= aArr)
304
0
                for (const auto& rC : aArr)
305
0
                    aD.maCopyrights.push_back({ rC });
306
0
        }
307
0
        else
308
0
        {
309
0
            OUString s;
310
0
            if (!(rProp.Value >>= s))
311
0
                continue;
312
0
            if (rProp.Name == "entityName")
313
0
                aD.mosEntityName = s;
314
0
            else if (rProp.Name == "entityId")
315
0
                aD.mosEntityId = s;
316
0
            else if (rProp.Name == "east")
317
0
                aD.mosEast = s;
318
0
            else if (rProp.Name == "west")
319
0
                aD.mosWest = s;
320
0
            else if (rProp.Name == "north")
321
0
                aD.mosNorth = s;
322
0
            else if (rProp.Name == "south")
323
0
                aD.mosSouth = s;
324
0
        }
325
0
    }
326
0
    return aD;
327
0
}
328
329
uno::Sequence<beans::PropertyValue> dataEntityQueryToProps(const GeoDataEntityQueryModel& rQ)
330
0
{
331
0
    std::vector<beans::PropertyValue> aVec;
332
0
    if (rQ.mosEntityType.has_value())
333
0
        aVec.push_back({ u"entityType"_ustr, 0, uno::Any(*rQ.mosEntityType),
334
0
                         beans::PropertyState_DIRECT_VALUE });
335
0
    if (rQ.mosEntityId.has_value())
336
0
        aVec.push_back(
337
0
            { u"entityId"_ustr, 0, uno::Any(*rQ.mosEntityId), beans::PropertyState_DIRECT_VALUE });
338
0
    return comphelper::containerToSequence(aVec);
339
0
}
340
341
GeoDataEntityQueryModel dataEntityQueryFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
342
0
{
343
0
    GeoDataEntityQueryModel aQ;
344
0
    for (const auto& rProp : rProps)
345
0
    {
346
0
        OUString s;
347
0
        if (!(rProp.Value >>= s))
348
0
            continue;
349
0
        if (rProp.Name == "entityType")
350
0
            aQ.mosEntityType = s;
351
0
        else if (rProp.Name == "entityId")
352
0
            aQ.mosEntityId = s;
353
0
    }
354
0
    return aQ;
355
0
}
356
357
uno::Sequence<beans::PropertyValue> dataEntityResultToProps(const GeoDataEntityQueryResultModel& rR)
358
0
{
359
0
    std::vector<beans::PropertyValue> aVec;
360
0
    if (rR.mxQuery.has_value())
361
0
        aVec.push_back({ u"query"_ustr, 0, uno::Any(dataEntityQueryToProps(*rR.mxQuery)),
362
0
                         beans::PropertyState_DIRECT_VALUE });
363
0
    if (rR.mxData.has_value())
364
0
        aVec.push_back({ u"data"_ustr, 0, uno::Any(geoDataToProps(*rR.mxData)),
365
0
                         beans::PropertyState_DIRECT_VALUE });
366
0
    return comphelper::containerToSequence(aVec);
367
0
}
368
369
GeoDataEntityQueryResultModel
370
dataEntityResultFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
371
0
{
372
0
    GeoDataEntityQueryResultModel aR;
373
0
    for (const auto& rProp : rProps)
374
0
    {
375
0
        uno::Sequence<beans::PropertyValue> aInner;
376
0
        if (!(rProp.Value >>= aInner))
377
0
            continue;
378
0
        if (rProp.Name == "query")
379
0
            aR.mxQuery = dataEntityQueryFromProps(aInner);
380
0
        else if (rProp.Name == "data")
381
0
            aR.mxData = geoDataFromProps(aInner);
382
0
    }
383
0
    return aR;
384
0
}
385
386
uno::Sequence<beans::PropertyValue> ptQueryToProps(const GeoDataPointQueryModel& rQ)
387
0
{
388
0
    std::vector<beans::PropertyValue> aVec;
389
0
    if (rQ.mosEntityType.has_value())
390
0
        aVec.push_back({ u"entityType"_ustr, 0, uno::Any(*rQ.mosEntityType),
391
0
                         beans::PropertyState_DIRECT_VALUE });
392
0
    if (rQ.mosLatitude.has_value())
393
0
        aVec.push_back(
394
0
            { u"latitude"_ustr, 0, uno::Any(*rQ.mosLatitude), beans::PropertyState_DIRECT_VALUE });
395
0
    if (rQ.mosLongitude.has_value())
396
0
        aVec.push_back({ u"longitude"_ustr, 0, uno::Any(*rQ.mosLongitude),
397
0
                         beans::PropertyState_DIRECT_VALUE });
398
0
    return comphelper::containerToSequence(aVec);
399
0
}
400
401
GeoDataPointQueryModel ptQueryFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
402
0
{
403
0
    GeoDataPointQueryModel aQ;
404
0
    for (const auto& rProp : rProps)
405
0
    {
406
0
        OUString s;
407
0
        if (!(rProp.Value >>= s))
408
0
            continue;
409
0
        if (rProp.Name == "entityType")
410
0
            aQ.mosEntityType = s;
411
0
        else if (rProp.Name == "latitude")
412
0
            aQ.mosLatitude = s;
413
0
        else if (rProp.Name == "longitude")
414
0
            aQ.mosLongitude = s;
415
0
    }
416
0
    return aQ;
417
0
}
418
419
uno::Sequence<beans::PropertyValue> ptEntityQueryToProps(const GeoDataPointToEntityQueryModel& rQ)
420
0
{
421
0
    std::vector<beans::PropertyValue> aVec;
422
0
    if (rQ.mosEntityType.has_value())
423
0
        aVec.push_back({ u"entityType"_ustr, 0, uno::Any(*rQ.mosEntityType),
424
0
                         beans::PropertyState_DIRECT_VALUE });
425
0
    if (rQ.mosEntityId.has_value())
426
0
        aVec.push_back(
427
0
            { u"entityId"_ustr, 0, uno::Any(*rQ.mosEntityId), beans::PropertyState_DIRECT_VALUE });
428
0
    return comphelper::containerToSequence(aVec);
429
0
}
430
431
GeoDataPointToEntityQueryModel
432
ptEntityQueryFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
433
0
{
434
0
    GeoDataPointToEntityQueryModel aQ;
435
0
    for (const auto& rProp : rProps)
436
0
    {
437
0
        OUString s;
438
0
        if (!(rProp.Value >>= s))
439
0
            continue;
440
0
        if (rProp.Name == "entityType")
441
0
            aQ.mosEntityType = s;
442
0
        else if (rProp.Name == "entityId")
443
0
            aQ.mosEntityId = s;
444
0
    }
445
0
    return aQ;
446
0
}
447
448
uno::Sequence<beans::PropertyValue> ptResultToProps(const GeoDataPointToEntityQueryResultModel& rR)
449
0
{
450
0
    std::vector<beans::PropertyValue> aVec;
451
0
    if (rR.mxPointQuery.has_value())
452
0
        aVec.push_back({ u"pointQuery"_ustr, 0, uno::Any(ptQueryToProps(*rR.mxPointQuery)),
453
0
                         beans::PropertyState_DIRECT_VALUE });
454
0
    if (rR.mxEntityQuery.has_value())
455
0
        aVec.push_back({ u"entityQuery"_ustr, 0, uno::Any(ptEntityQueryToProps(*rR.mxEntityQuery)),
456
0
                         beans::PropertyState_DIRECT_VALUE });
457
0
    return comphelper::containerToSequence(aVec);
458
0
}
459
460
GeoDataPointToEntityQueryResultModel
461
ptResultFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
462
0
{
463
0
    GeoDataPointToEntityQueryResultModel aR;
464
0
    for (const auto& rProp : rProps)
465
0
    {
466
0
        uno::Sequence<beans::PropertyValue> aInner;
467
0
        if (!(rProp.Value >>= aInner))
468
0
            continue;
469
0
        if (rProp.Name == "pointQuery")
470
0
            aR.mxPointQuery = ptQueryFromProps(aInner);
471
0
        else if (rProp.Name == "entityQuery")
472
0
            aR.mxEntityQuery = ptEntityQueryFromProps(aInner);
473
0
    }
474
0
    return aR;
475
0
}
476
477
uno::Sequence<beans::PropertyValue> childQueryToProps(const GeoChildEntitiesQueryModel& rQ)
478
0
{
479
0
    std::vector<beans::PropertyValue> aVec;
480
0
    if (rQ.mosEntityId.has_value())
481
0
        aVec.push_back(
482
0
            { u"entityId"_ustr, 0, uno::Any(*rQ.mosEntityId), beans::PropertyState_DIRECT_VALUE });
483
0
    if (!rQ.maEntityTypes.empty())
484
0
        aVec.push_back({ u"entityTypes"_ustr, 0,
485
0
                         uno::Any(comphelper::containerToSequence(rQ.maEntityTypes)),
486
0
                         beans::PropertyState_DIRECT_VALUE });
487
0
    return comphelper::containerToSequence(aVec);
488
0
}
489
490
GeoChildEntitiesQueryModel childQueryFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
491
0
{
492
0
    GeoChildEntitiesQueryModel aQ;
493
0
    for (const auto& rProp : rProps)
494
0
    {
495
0
        if (rProp.Name == "entityId")
496
0
        {
497
0
            OUString s;
498
0
            if (rProp.Value >>= s)
499
0
                aQ.mosEntityId = s;
500
0
        }
501
0
        else if (rProp.Name == "entityTypes")
502
0
        {
503
0
            uno::Sequence<OUString> aArr;
504
0
            if (rProp.Value >>= aArr)
505
0
                for (const auto& rS : aArr)
506
0
                    aQ.maEntityTypes.push_back(rS);
507
0
        }
508
0
    }
509
0
    return aQ;
510
0
}
511
512
uno::Sequence<beans::PropertyValue> hierarchyEntityToProps(const GeoHierarchyEntityModel& rE)
513
0
{
514
0
    std::vector<beans::PropertyValue> aVec;
515
0
    if (rE.mosEntityName.has_value())
516
0
        aVec.push_back({ u"entityName"_ustr, 0, uno::Any(*rE.mosEntityName),
517
0
                         beans::PropertyState_DIRECT_VALUE });
518
0
    if (rE.mosEntityId.has_value())
519
0
        aVec.push_back(
520
0
            { u"entityId"_ustr, 0, uno::Any(*rE.mosEntityId), beans::PropertyState_DIRECT_VALUE });
521
0
    if (rE.mosEntityType.has_value())
522
0
        aVec.push_back({ u"entityType"_ustr, 0, uno::Any(*rE.mosEntityType),
523
0
                         beans::PropertyState_DIRECT_VALUE });
524
0
    return comphelper::containerToSequence(aVec);
525
0
}
526
527
GeoHierarchyEntityModel hierarchyEntityFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
528
0
{
529
0
    GeoHierarchyEntityModel aE;
530
0
    for (const auto& rProp : rProps)
531
0
    {
532
0
        OUString s;
533
0
        if (!(rProp.Value >>= s))
534
0
            continue;
535
0
        if (rProp.Name == "entityName")
536
0
            aE.mosEntityName = s;
537
0
        else if (rProp.Name == "entityId")
538
0
            aE.mosEntityId = s;
539
0
        else if (rProp.Name == "entityType")
540
0
            aE.mosEntityType = s;
541
0
    }
542
0
    return aE;
543
0
}
544
545
uno::Sequence<beans::PropertyValue> childResultToProps(const GeoChildEntitiesQueryResultModel& rR)
546
0
{
547
0
    std::vector<beans::PropertyValue> aVec;
548
0
    if (rR.mxQuery.has_value())
549
0
        aVec.push_back({ u"query"_ustr, 0, uno::Any(childQueryToProps(*rR.mxQuery)),
550
0
                         beans::PropertyState_DIRECT_VALUE });
551
0
    if (!rR.maEntities.empty())
552
0
    {
553
0
        std::vector<uno::Sequence<beans::PropertyValue>> aArr;
554
0
        for (const auto& rE : rR.maEntities)
555
0
            aArr.push_back(hierarchyEntityToProps(rE));
556
0
        aVec.push_back({ u"entities"_ustr, 0, uno::Any(comphelper::containerToSequence(aArr)),
557
0
                         beans::PropertyState_DIRECT_VALUE });
558
0
    }
559
0
    return comphelper::containerToSequence(aVec);
560
0
}
561
562
GeoChildEntitiesQueryResultModel
563
childResultFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
564
0
{
565
0
    GeoChildEntitiesQueryResultModel aR;
566
0
    for (const auto& rProp : rProps)
567
0
    {
568
0
        if (rProp.Name == "query")
569
0
        {
570
0
            uno::Sequence<beans::PropertyValue> aInner;
571
0
            if (rProp.Value >>= aInner)
572
0
                aR.mxQuery = childQueryFromProps(aInner);
573
0
        }
574
0
        else if (rProp.Name == "entities")
575
0
        {
576
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
577
0
            if (rProp.Value >>= aArr)
578
0
                for (const auto& rE : aArr)
579
0
                    aR.maEntities.push_back(hierarchyEntityFromProps(rE));
580
0
        }
581
0
    }
582
0
    return aR;
583
0
}
584
585
uno::Sequence<beans::PropertyValue> parentResultToProps(const GeoParentEntitiesQueryResultModel& rR)
586
0
{
587
0
    std::vector<beans::PropertyValue> aVec;
588
0
    if (rR.mxQuery.has_value())
589
0
    {
590
0
        std::vector<beans::PropertyValue> aQ;
591
0
        if (rR.mxQuery->mosEntityId.has_value())
592
0
            aQ.push_back({ u"entityId"_ustr, 0, uno::Any(*rR.mxQuery->mosEntityId),
593
0
                           beans::PropertyState_DIRECT_VALUE });
594
0
        aVec.push_back({ u"query"_ustr, 0, uno::Any(comphelper::containerToSequence(aQ)),
595
0
                         beans::PropertyState_DIRECT_VALUE });
596
0
    }
597
0
    if (rR.mxEntity.has_value())
598
0
    {
599
0
        std::vector<beans::PropertyValue> aE;
600
0
        if (rR.mxEntity->mosEntityName.has_value())
601
0
            aE.push_back({ u"entityName"_ustr, 0, uno::Any(*rR.mxEntity->mosEntityName),
602
0
                           beans::PropertyState_DIRECT_VALUE });
603
0
        if (rR.mxEntity->mosEntityType.has_value())
604
0
            aE.push_back({ u"entityType"_ustr, 0, uno::Any(*rR.mxEntity->mosEntityType),
605
0
                           beans::PropertyState_DIRECT_VALUE });
606
0
        aVec.push_back({ u"entity"_ustr, 0, uno::Any(comphelper::containerToSequence(aE)),
607
0
                         beans::PropertyState_DIRECT_VALUE });
608
0
    }
609
0
    if (rR.mxParentEntity.has_value())
610
0
    {
611
0
        std::vector<beans::PropertyValue> aP;
612
0
        if (rR.mxParentEntity->mosEntityId.has_value())
613
0
            aP.push_back({ u"entityId"_ustr, 0, uno::Any(*rR.mxParentEntity->mosEntityId),
614
0
                           beans::PropertyState_DIRECT_VALUE });
615
0
        aVec.push_back({ u"parentEntity"_ustr, 0, uno::Any(comphelper::containerToSequence(aP)),
616
0
                         beans::PropertyState_DIRECT_VALUE });
617
0
    }
618
0
    return comphelper::containerToSequence(aVec);
619
0
}
620
621
GeoParentEntitiesQueryResultModel
622
parentResultFromProps(const uno::Sequence<beans::PropertyValue>& rProps)
623
0
{
624
0
    GeoParentEntitiesQueryResultModel aR;
625
0
    for (const auto& rProp : rProps)
626
0
    {
627
0
        uno::Sequence<beans::PropertyValue> aInner;
628
0
        if (!(rProp.Value >>= aInner))
629
0
            continue;
630
0
        if (rProp.Name == "query")
631
0
        {
632
0
            aR.mxQuery.emplace();
633
0
            for (const auto& rQ : aInner)
634
0
            {
635
0
                OUString s;
636
0
                if (rQ.Name == "entityId" && (rQ.Value >>= s))
637
0
                    aR.mxQuery->mosEntityId = s;
638
0
            }
639
0
        }
640
0
        else if (rProp.Name == "entity")
641
0
        {
642
0
            aR.mxEntity.emplace();
643
0
            for (const auto& rE : aInner)
644
0
            {
645
0
                OUString s;
646
0
                if (!(rE.Value >>= s))
647
0
                    continue;
648
0
                if (rE.Name == "entityName")
649
0
                    aR.mxEntity->mosEntityName = s;
650
0
                else if (rE.Name == "entityType")
651
0
                    aR.mxEntity->mosEntityType = s;
652
0
            }
653
0
        }
654
0
        else if (rProp.Name == "parentEntity")
655
0
        {
656
0
            aR.mxParentEntity.emplace();
657
0
            for (const auto& rP : aInner)
658
0
            {
659
0
                OUString s;
660
0
                if (rP.Name == "entityId" && (rP.Value >>= s))
661
0
                    aR.mxParentEntity->mosEntityId = s;
662
0
            }
663
0
        }
664
0
    }
665
0
    return aR;
666
0
}
667
668
} // anonymous namespace
669
670
uno::Sequence<beans::PropertyValue> geoClearToPropertyValues(const GeoClearModel& rModel)
671
0
{
672
0
    std::vector<beans::PropertyValue> aVec;
673
674
0
    if (!rModel.maLocResults.empty())
675
0
    {
676
0
        std::vector<uno::Sequence<beans::PropertyValue>> aArr;
677
0
        for (const auto& rR : rModel.maLocResults)
678
0
            aArr.push_back(locResultToProps(rR));
679
0
        aVec.push_back({ u"locResults"_ustr, 0, uno::Any(comphelper::containerToSequence(aArr)),
680
0
                         beans::PropertyState_DIRECT_VALUE });
681
0
    }
682
0
    if (!rModel.maDataResults.empty())
683
0
    {
684
0
        std::vector<uno::Sequence<beans::PropertyValue>> aArr;
685
0
        for (const auto& rR : rModel.maDataResults)
686
0
            aArr.push_back(dataEntityResultToProps(rR));
687
0
        aVec.push_back({ u"dataResults"_ustr, 0, uno::Any(comphelper::containerToSequence(aArr)),
688
0
                         beans::PropertyState_DIRECT_VALUE });
689
0
    }
690
0
    if (!rModel.maPtResults.empty())
691
0
    {
692
0
        std::vector<uno::Sequence<beans::PropertyValue>> aArr;
693
0
        for (const auto& rR : rModel.maPtResults)
694
0
            aArr.push_back(ptResultToProps(rR));
695
0
        aVec.push_back({ u"ptResults"_ustr, 0, uno::Any(comphelper::containerToSequence(aArr)),
696
0
                         beans::PropertyState_DIRECT_VALUE });
697
0
    }
698
0
    if (!rModel.maChildResults.empty())
699
0
    {
700
0
        std::vector<uno::Sequence<beans::PropertyValue>> aArr;
701
0
        for (const auto& rR : rModel.maChildResults)
702
0
            aArr.push_back(childResultToProps(rR));
703
0
        aVec.push_back({ u"childResults"_ustr, 0, uno::Any(comphelper::containerToSequence(aArr)),
704
0
                         beans::PropertyState_DIRECT_VALUE });
705
0
    }
706
0
    if (!rModel.maParentResults.empty())
707
0
    {
708
0
        std::vector<uno::Sequence<beans::PropertyValue>> aArr;
709
0
        for (const auto& rR : rModel.maParentResults)
710
0
            aArr.push_back(parentResultToProps(rR));
711
0
        aVec.push_back({ u"parentResults"_ustr, 0, uno::Any(comphelper::containerToSequence(aArr)),
712
0
                         beans::PropertyState_DIRECT_VALUE });
713
0
    }
714
715
0
    return comphelper::containerToSequence(aVec);
716
0
}
717
718
GeoClearModel geoClearFromPropertyValues(const uno::Sequence<beans::PropertyValue>& rProps)
719
0
{
720
0
    GeoClearModel aModel;
721
0
    for (const auto& rProp : rProps)
722
0
    {
723
0
        if (rProp.Name == "locResults")
724
0
        {
725
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
726
0
            if (rProp.Value >>= aArr)
727
0
                for (const auto& rR : aArr)
728
0
                    aModel.maLocResults.push_back(locResultFromProps(rR));
729
0
        }
730
0
        else if (rProp.Name == "dataResults")
731
0
        {
732
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
733
0
            if (rProp.Value >>= aArr)
734
0
                for (const auto& rR : aArr)
735
0
                    aModel.maDataResults.push_back(dataEntityResultFromProps(rR));
736
0
        }
737
0
        else if (rProp.Name == "ptResults")
738
0
        {
739
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
740
0
            if (rProp.Value >>= aArr)
741
0
                for (const auto& rR : aArr)
742
0
                    aModel.maPtResults.push_back(ptResultFromProps(rR));
743
0
        }
744
0
        else if (rProp.Name == "childResults")
745
0
        {
746
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
747
0
            if (rProp.Value >>= aArr)
748
0
                for (const auto& rR : aArr)
749
0
                    aModel.maChildResults.push_back(childResultFromProps(rR));
750
0
        }
751
0
        else if (rProp.Name == "parentResults")
752
0
        {
753
0
            uno::Sequence<uno::Sequence<beans::PropertyValue>> aArr;
754
0
            if (rProp.Value >>= aArr)
755
0
                for (const auto& rR : aArr)
756
0
                    aModel.maParentResults.push_back(parentResultFromProps(rR));
757
0
        }
758
0
    }
759
0
    return aModel;
760
0
}
761
762
void convertGeography(const GeographyModel& rModel, PropertySet& rSeriesProp)
763
0
{
764
0
    if (rModel.moeProjectionType.has_value())
765
0
        rSeriesProp.setProperty(PROP_GeographyProjectionType,
766
0
                                static_cast<sal_Int32>(*rModel.moeProjectionType));
767
0
    if (rModel.moeViewedRegionType.has_value())
768
0
        rSeriesProp.setProperty(PROP_GeographyViewedRegionType,
769
0
                                static_cast<sal_Int32>(*rModel.moeViewedRegionType));
770
0
    if (rModel.mosCultureLanguage.has_value())
771
0
        rSeriesProp.setProperty(PROP_GeographyCultureLanguage, *rModel.mosCultureLanguage);
772
0
    if (rModel.mosCultureRegion.has_value())
773
0
        rSeriesProp.setProperty(PROP_GeographyCultureRegion, *rModel.mosCultureRegion);
774
0
    if (rModel.mosAttribution.has_value())
775
0
        rSeriesProp.setProperty(PROP_GeographyAttribution, *rModel.mosAttribution);
776
777
0
    if (rModel.mxGeoCache.has_value())
778
0
    {
779
0
        const auto& rCache = *rModel.mxGeoCache;
780
0
        if (rCache.mosProvider.has_value())
781
0
            rSeriesProp.setProperty(PROP_GeoCacheProvider, *rCache.mosProvider);
782
0
        if (rCache.mosBinary.has_value())
783
0
            rSeriesProp.setProperty(PROP_GeoCacheBinary, *rCache.mosBinary);
784
0
        if (rCache.mxClear.has_value())
785
0
            rSeriesProp.setProperty(PROP_GeoCacheClearData,
786
0
                                    geoClearToPropertyValues(*rCache.mxClear));
787
0
    }
788
0
}
789
790
} // namespace oox::drawingml::chart
791
792
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */