Coverage Report

Created: 2026-06-30 11:14

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/libreoffice/xmloff/source/style/XMLFillBitmapSizePropertyHandler.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
 * 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
21
#include <XMLFillBitmapSizePropertyHandler.hxx>
22
#include <rtl/ustrbuf.hxx>
23
#include <com/sun/star/uno/Any.hxx>
24
#include <sax/tools/converter.hxx>
25
#include <xmloff/xmluconv.hxx>
26
27
using namespace ::com::sun::star;
28
using namespace ::com::sun::star::uno;
29
30
31
XMLFillBitmapSizePropertyHandler::XMLFillBitmapSizePropertyHandler()
32
85.6k
{
33
85.6k
}
34
35
XMLFillBitmapSizePropertyHandler::~XMLFillBitmapSizePropertyHandler()
36
85.6k
{
37
85.6k
}
38
39
bool XMLFillBitmapSizePropertyHandler::importXML(
40
    const OUString& rStrImpValue,
41
    Any& rValue,
42
    const SvXMLUnitConverter& rUnitConverter ) const
43
4
{
44
4
    sal_Int32 nValue;
45
4
    bool bRet;
46
47
4
    if( rStrImpValue.indexOf( '%' ) != -1 )
48
0
    {
49
0
        bRet = ::sax::Converter::convertPercent( nValue, rStrImpValue );
50
0
        nValue *= -1;
51
0
    }
52
4
    else
53
4
    {
54
4
        bRet = rUnitConverter.convertMeasureToCore( nValue, rStrImpValue );
55
4
    }
56
57
4
    if( bRet )
58
4
        rValue <<= nValue;
59
60
4
    return bRet;
61
4
}
62
63
bool XMLFillBitmapSizePropertyHandler::exportXML(
64
    OUString& rStrExpValue,
65
    const Any& rValue,
66
    const SvXMLUnitConverter& rUnitConverter ) const
67
28
{
68
28
    sal_Int32 nValue = 0;
69
28
    if( rValue >>= nValue )
70
28
    {
71
28
        OUStringBuffer aOut;
72
28
        if( nValue < 0 )
73
0
        {
74
0
            ::sax::Converter::convertPercent( aOut, -nValue );
75
0
        }
76
28
        else
77
28
        {
78
28
            rUnitConverter.convertMeasureToXML( aOut, nValue );
79
28
        }
80
81
28
        rStrExpValue = aOut.makeStringAndClear();
82
28
        return true;
83
28
    }
84
85
0
    return false;
86
28
}
87
88
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */