summaryrefslogtreecommitdiff
path: root/test/source/sheet/xnamedrange.cxx
blob: c0a837fc14208eca8715189fa9bfa99724999ba1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * Version: MPL 1.1 / GPLv3+ / LGPLv3+
 *
 * The contents of this file are subject to the Mozilla Public License Version
 * 1.1 (the "License"); you may not use this file except in compliance with
 * the License or as specified alternatively below. You may obtain a copy of
 * the License at http://www.mozilla.org/MPL/
 *
 * Software distributed under the License is distributed on an "AS IS" basis,
 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 * for the specific language governing rights and limitations under the
 * License.
 *
 * Major Contributor(s):
 * Copyright (C) 2011 Laurent Godard lgodard.libre@laposte.net (initial developer)
 *
 * All Rights Reserved.
 *
 * For minor contributions see the git repository.
 *
 * Alternatively, the contents of this file may be used under the terms of
 * either the GNU General Public License Version 3 or later (the "GPLv3+"), or
 * the GNU Lesser General Public License Version 3 or later (the "LGPLv3+"),
 * in which case the provisions of the GPLv3+ or the LGPLv3+ are applicable
 * instead of those above.
 */

#include <test/sheet/xnamedrange.hxx>

#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/sheet/XSpreadsheetDocument.hpp>
#include <com/sun/star/sheet/XSpreadsheet.hpp>
#include <com/sun/star/table/XCellRange.hpp>
#include <com/sun/star/sheet/XCellRangeAddressable.hpp>
#include <com/sun/star/sheet/XCellRangeReferrer.hpp>
#include <com/sun/star/sheet/XNamedRanges.hpp>
#include <com/sun/star/sheet/XNamedRange.hpp>
#include <com/sun/star/table/XCell.hpp>
#include <com/sun/star/text/XTextRange.hpp>

#include <com/sun/star/table/CellAddress.hpp>
#include <com/sun/star/table/CellRangeAddress.hpp>
#include <com/sun/star/sheet/Border.hpp>
#include <com/sun/star/sheet/NamedRangeFlag.hpp>

#include "cppunit/extensions/HelperMacros.h"
#include <rtl/ustring.hxx>

using namespace css;
using namespace css::uno;

namespace apitest {

void XNamedRange::testGetContent()
{
    OUString aTestedNamedRangeString("initial1");
    uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);

    OUString aExpectedContent("$Sheet1.$B$1");
    CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 on GetContent", xNamedRange->getContent().equals(aExpectedContent));
}

void XNamedRange::testSetContent()
{
    OUString aTestedNamedRangeString("initial1");
    uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);

    OUString aExpectedContent;

    // test a cell
    aExpectedContent = OUString("D1");
    xNamedRange->setContent(aExpectedContent);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cell", xNamedRange->getContent().equals(aExpectedContent));

    // test a cellrange
    aExpectedContent = OUString("D1:D10");
    xNamedRange->setContent(aExpectedContent);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a cellrange", xNamedRange->getContent().equals(aExpectedContent));

    // test a formula
    aExpectedContent = OUString("=D10");
    xNamedRange->setContent(aExpectedContent);
    aExpectedContent = OUString("D10");
    CPPUNIT_ASSERT_MESSAGE("Wrong expected content for initial1 after SetContent a formula", xNamedRange->getContent().equals(aExpectedContent));

}

void XNamedRange::testGetType()
{
    OUString aTestedNamedRangeString("initial1");
    uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected Type", xNamedRange->getType() == 0);
}

void XNamedRange::testSetType()
{
    OUString aTestedNamedRangeString("initial1");
    uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);

    sal_Int32 nType = ::sheet::NamedRangeFlag::ROW_HEADER;;
    xNamedRange->setType(nType);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected Type ROW_HEADER after setting it", xNamedRange->getType() == nType);

    nType = ::sheet::NamedRangeFlag::COLUMN_HEADER;
    xNamedRange->setType(nType);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected Type COLUMN_HEADER after setting it", xNamedRange->getType() == nType);

    nType = ::sheet::NamedRangeFlag::FILTER_CRITERIA;
    xNamedRange->setType(nType);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected Type FILTER_CRITERIA after setting it", xNamedRange->getType() == nType);

    nType = ::sheet::NamedRangeFlag::PRINT_AREA;
    xNamedRange->setType(nType);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected Type PRINT_AREA after setting it", xNamedRange->getType() == nType);

    nType = 0;
    xNamedRange->setType(nType);
    CPPUNIT_ASSERT_MESSAGE("Wrong expected Type 0 after setting it", xNamedRange->getType() == nType);
}

void XNamedRange::testGetReferencePosition()
{
    OUString aTestedNamedRangeString("initial2");
    uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);

    table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
    // the expeted address is on B1, as it was the active cell when intial2 created
    CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position", xCellAddress.Sheet == 0);
    CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position", xCellAddress.Column == 1);
    CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position", xCellAddress.Row == 0);
}

void XNamedRange::testSetReferencePosition()
{
    OUString aTestedNamedRangeString("initial1");
    uno::Reference< sheet::XNamedRange > xNamedRange = getNamedRange(aTestedNamedRangeString);

    table::CellAddress aBaseAddress = table::CellAddress(1,2,3);

    xNamedRange->setReferencePosition(aBaseAddress);

    table::CellAddress xCellAddress = xNamedRange->getReferencePosition();
    CPPUNIT_ASSERT_MESSAGE("Wrong SHEET reference position after setting it", xCellAddress.Sheet == 1);
    CPPUNIT_ASSERT_MESSAGE("Wrong COLUMN reference position after setting it", xCellAddress.Column == 2);
    CPPUNIT_ASSERT_MESSAGE("Wrong ROW reference position after setting it", xCellAddress.Row == 3);
}



}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
t;std::unordered_mapCaolán McNamara Change-Id: I82f668ef72e916d2ff11df5cda2a02653999f66f 2014-11-17sal: clean up public headers with include-what-you-useMichael Stahl Sadly cannot forward declare "struct {...} TimeValue;". rtl/(u)?string.hxx still include sal/log.hxx but removing osl/diagnose.h was painful enough for now... Change-Id: Id41e17f3870c4f24c53ce7b11f2c40a3d14d1f05 2014-10-03rename SvRef::AddRef to AddFirstRefNoel Grandin to make it's intended purpose clearly distinguishable from AddNextRef Change-Id: I5da780b48b19fd873667b648031bc394113f953b Reviewed-on: https://gerrit.libreoffice.org/11763 Reviewed-by: Noel Grandin <noelgrandin@gmail.com> Tested-by: Noel Grandin <noelgrandin@gmail.com> 2014-09-29loplugin: cstylecastNoel Grandin Change-Id: I28443b688f8ab752162846e5cea661f26d269cad 2014-08-18ErrorBox->MessageDialogCaolán McNamara Change-Id: I57d4e43460e40d3aff54873280eddbb18c12446b 2014-07-10use SimpleReferenceObject in StgPageNoel Grandin to replace hand-rolled version Change-Id: I5301ef1df786b08b3c5d585a366d95722506f220 2014-04-20coverity#705538 Unintentional integer overflowCaolán McNamara Change-Id: I50f0701bea8f2f2e00a6b1396ba7cfbf5e0bd00c 2014-02-25Remove visual noise from sotAlexander Wilms Change-Id: I731691d4cac8567938407a514a25e13b2baa7958 Reviewed-on: https://gerrit.libreoffice.org/8314 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> 2013-07-04module sot: String, bool and other clean-upNorbert Thiebaud Change-Id: Ibe2bfdf20c500e9fd98c3baef66d36aa79ca4b52 Reviewed-on: https://gerrit.libreoffice.org/4710 Tested-by: LibreOffice gerrit bot <gerrit@libreoffice.org> Reviewed-by: Fridrich Strba <fridrich@documentfoundation.org> Tested-by: Fridrich Strba <fridrich@documentfoundation.org> 2013-03-03Related to fdo#60724: correct spellingThomas Arnhold Using the autocorrect list of LibreOffice extras/source/autotext/lang/en-US/acor/DocumentList.xml Change-Id: I8b93969bc0742c2e95b8b7db3c4c37691e8d3657 Script: http://pastebin.ca/2327716 2012-10-13Prefer prefix ++/-- operators for non-primitive typesJulien Nabet + replace "<" by "!=" for end iterator comparison with current it Change-Id: I6e90caa8752c7057cca8c74fca12c0a050544dbb 2012-10-12mark lcl_ functions static or rename them if they are not local at allLuboš Luňák http://lists.freedesktop.org/archives/libreoffice/2012-October/039639.html Change-Id: I1a0e436051d48e7f6224d6f0fc602347df2d4df1 2012-09-20sot: memory savings to avoid duplicating the whole stream in RAMMichael Meeks re-work LRU cache to really be an 8 entry LRU cache. only force dirty pages to stay in memory, hopefully huge reads should now stream through memory. Change-Id: I0bedc762086f5f02202795568743750aefaaa50b 2012-09-19sot: stgcache re-factor to use sane lifecycle semanticsMichael Meeks Store a dirty page hash to allow us to fix the LRU cache next. Change-Id: I67130af37ac1bc2d0a4abbb11f4d9871bb2bc306 2012-09-19sot: substantially accelerate sorted cache write-outMichael Meeks Sort only the pages we want to write out, at the end, using a std::sort instead of a hand-crafted linked-list mess maintained during use. Cleanup StgPage as well, de-friend it from StgCache, clean member names. Remove unused pCache member as well. Change-Id: I0f53d1f85be373fce0d504b226d34ccaf575b2b3 2012-09-19sot: remove un-used LRU cacheMichael Meeks Change-Id: I3d011a1aae47b6961b1cea2bf544af2c88bd611e 2012-09-19sot: remove horrible hiding of LRU cache mapMichael Meeks Change-Id: Ic8df1012752e78d3326999a07dc15a99e982b896 2012-09-19sot: remove unused Owner construct on StgPageMichael Meeks Change-Id: Idd6616ac11e16b4c4631c607a3dc92417a796521 2012-08-20callcatcher: remove some of the slightly trickier unused methodsCaolán McNamara Change-Id: Ief164c980f3a92316e1f47cb50bdf243155b6dd9 2012-07-27sot: prevent some null pointer crashesMikhail Voytenko 2012-06-22re-base on ALv2 code.Michael Meeks 2012-01-31SWAPLONG -> OSL_SWAPDWORDStephan Bergmann 2012-01-21Removed some unused parameters; added SAL_UNUSED_PARAMETER.Stephan Bergmann SAL_UNUSED_PARAMETER (expanding to __attribute__ ((unused)) for GCC) is used to annotate legitimately unused parameters, so that static analysis tools can tell legitimately unused parameters from truly unnecessary ones. To that end, some patches for external modules are also added, that are only applied when compiling with GCC and add necessary __attribute__ ((unused)) in headers. 2011-11-27remove include of pch header from sotNorbert Thiebaud