summaryrefslogtreecommitdiff
path: root/sc/source/ui/miscdlgs/tabbgcolordlg.cxx
blob: 60b1d6d9751d9c5c0f270e86588b609a6b25b8ab (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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
 * This file is part of the LibreOffice project.
 *
 * This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/.
 *
 * This file incorporates work covered by the following license notice:
 *
 *   Licensed to the Apache Software Foundation (ASF) under one or more
 *   contributor license agreements. See the NOTICE file distributed
 *   with this work for additional information regarding copyright
 *   ownership. The ASF licenses this file to you under the Apache
 *   License, Version 2.0 (the "License"); you may not use this file
 *   except in compliance with the License. You may obtain a copy of
 *   the License at http://www.apache.org/licenses/LICENSE-2.0 .
 */

#undef SC_DLLIMPLEMENTATION

#include "tabbgcolordlg.hxx"
#include "scresid.hxx"
#include "miscdlgs.hrc"

#include <tools/color.hxx>
#include <sfx2/objsh.hxx>
#include <svx/xtable.hxx>
#include <svx/drawitem.hxx>
#include <unotools/pathoptions.hxx>
#include <tools/resid.hxx>
#include <editeng/editrids.hrc>
#include <editeng/eerdll.hxx>
#include <vcl/builderfactory.hxx>

#define HDL(hdl) LINK(this,ScTabBgColorDlg,hdl)

ScTabBgColorDlg::ScTabBgColorDlg(vcl::Window* pParent, const OUString& rTitle,
    const OUString& rTabBgColorNoColorText, const Color& rDefaultColor,
    const OString& sHelpId)
    : ModalDialog(pParent, "TabColorDialog", "modules/scalc/ui/tabcolordialog.ui")
    , m_aTabBgColor(rDefaultColor)
    , m_aTabBgColorNoColorText(rTabBgColorNoColorText)

{
    get(m_pTabBgColorSet, "colorset");
    m_pTabBgColorSet->SetDialog(this);
    m_pTabBgColorSet->SetColCount(SvxColorValueSet::getColumnCount());
    get(m_pBtnOk, "ok");

    SetHelpId( sHelpId );
    this->SetText( rTitle );
    this->SetStyle(GetStyle() | WB_BORDER | WB_STDFLOATWIN | WB_3DLOOK | WB_DIALOGCONTROL | WB_SYSTEMWINDOW | WB_STANDALONE | WB_HIDE);

    FillColorValueSets_Impl();
    m_pTabBgColorSet->SetDoubleClickHdl( HDL(TabBgColorDblClickHdl_Impl) );
    m_pBtnOk->SetClickHdl( HDL(TabBgColorOKHdl_Impl) );
}

ScTabBgColorDlg::~ScTabBgColorDlg()
{
    disposeOnce();
}

void ScTabBgColorDlg::dispose()
{
    m_pTabBgColorSet.clear();
    m_pBtnOk.clear();
    ModalDialog::dispose();
}

void ScTabBgColorDlg::GetSelectedColor( Color& rColor ) const
{
    rColor = this->m_aTabBgColor;
}

void ScTabBgColorDlg::FillColorValueSets_Impl()
{
    SfxObjectShell* pDocSh = SfxObjectShell::Current();
    const SfxPoolItem* pItem = NULL;
    XColorListRef pColorList;

    sal_uInt16 nSelectedItem = 0;

    OSL_ENSURE( pDocSh, "DocShell not found!" );

    if ( pDocSh && ( 0 != ( pItem = pDocSh->GetItem(SID_COLOR_TABLE) ) ) )
        pColorList = static_cast<const SvxColorListItem*>(pItem)->GetColorList();
    if ( !pColorList.is() )
        pColorList = XColorList::CreateStdColorList();

    long nColorCount(0);

    if ( pColorList.is() )
    {
        nColorCount = pColorList->Count();
        m_pTabBgColorSet->addEntriesForXColorList(*pColorList);
    }

    if (nColorCount)
    {
        const WinBits nBits(m_pTabBgColorSet->GetStyle() | WB_NAMEFIELD | WB_ITEMBORDER | WB_NONEFIELD | WB_3DLOOK | WB_NO_DIRECTSELECT | WB_NOPOINTERFOCUS);
        m_pTabBgColorSet->SetText( m_aTabBgColorNoColorText );
        m_pTabBgColorSet->SetStyle( nBits );
    }

    //lock down a preferred size
    const sal_uInt32 nColCount = SvxColorValueSet::getColumnCount();
    const sal_uInt32 nRowCount(ceil(double(nColorCount)/nColCount));
    const sal_uInt32 nLength = SvxColorValueSet::getEntryEdgeLength();
    Size aSize(m_pTabBgColorSet->CalcWindowSizePixel(Size(nLength, nLength), nColCount, nRowCount));
    m_pTabBgColorSet->set_width_request(aSize.Width()+8);
    m_pTabBgColorSet->set_height_request(aSize.Height()+8);

    m_pTabBgColorSet->SelectItem(nSelectedItem);
}

///    Handler, called when color selection is changed
IMPL_LINK_NOARG_TYPED(ScTabBgColorDlg, TabBgColorDblClickHdl_Impl, ValueSet*, void)
{
    sal_uInt16 nItemId = m_pTabBgColorSet->GetSelectItemId();
    Color aColor = nItemId ? ( m_pTabBgColorSet->GetItemColor( nItemId ) ) : Color( COL_AUTO );
    m_aTabBgColor = aColor;
    EndDialog( RET_OK );
}

//    Handler, called when the OK button is pushed
IMPL_LINK_NOARG_TYPED(ScTabBgColorDlg, TabBgColorOKHdl_Impl, Button*, void)
{
    sal_uInt16 nItemId = m_pTabBgColorSet->GetSelectItemId();
    Color aColor = nItemId ? ( m_pTabBgColorSet->GetItemColor( nItemId ) ) : Color( COL_AUTO );
    m_aTabBgColor = aColor;
    EndDialog( RET_OK );
}

ScTabBgColorDlg::ScTabBgColorValueSet::ScTabBgColorValueSet(vcl::Window* pParent, WinBits nStyle)
    : SvxColorValueSet(pParent, nStyle)
    , m_pTabBgColorDlg(NULL)
{
}

ScTabBgColorDlg::ScTabBgColorValueSet::~ScTabBgColorValueSet()
{
    disposeOnce();
}

void ScTabBgColorDlg::ScTabBgColorValueSet::dispose()
{
    m_pTabBgColorDlg.clear();
    SvxColorValueSet::dispose();
}

VCL_BUILDER_DECL_FACTORY(ScTabBgColorValueSet)
{
    WinBits nWinBits = WB_TABSTOP;

    OString sBorder = VclBuilder::extractCustomProperty(rMap);
    if (!sBorder.isEmpty())
       nWinBits |= WB_BORDER;

    rRet = VclPtr<ScTabBgColorDlg::ScTabBgColorValueSet>::Create(pParent, nWinBits);
}

void ScTabBgColorDlg::ScTabBgColorValueSet::KeyInput( const KeyEvent& rKEvt )
{
    switch ( rKEvt.GetKeyCode().GetCode() )
    {
        case KEY_SPACE:
        case KEY_RETURN:
        {
            sal_uInt16 nItemId = GetSelectItemId();
            const Color& aColor = nItemId ? ( GetItemColor( nItemId ) ) : Color( COL_AUTO );
            m_pTabBgColorDlg->m_aTabBgColor = aColor;
            m_pTabBgColorDlg->EndDialog(RET_OK);
        }
        break;
    }
    SvxColorValueSet::KeyInput(rKEvt);
}

/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
s='decoration'>Regina Henschel This is about customs shapes in 3D mode using direction floater. Shapes, which were created with older versions, keep their values until the direction is newly assigned. So the change will not automatically change existing documents. Change-Id: Ib1ce511de0f524bf59279fb4e976f66ed65bc080 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112474 Tested-by: Jenkins Reviewed-by: Regina Henschel <rb.henschel@t-online.de> 2021-01-09fix coverity parse errorsCaolán McNamara Change-Id: I3a1179947704452e3ffec02be59d0f7bf0b75ab0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109017 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com> 2020-12-26New loplugin:stringliteralvarStephan Bergmann See the comment at the top of compilerplugins/clang/stringliteralvar.cxx for details. (Turned some affected variables in included files into inline variables, to avoid GCC warnings about unused variables.) Change-Id: Ie77219e6adfdaaceaa8b4e590b08971f2f04c83a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108239 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> 2020-08-06loplugin:flatten in svxNoel Grandin Change-Id: I31f33a5f693d5fdb8282181c5bd7f31971efe784 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100236 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2020-04-22tdf#42949 Simplify use of rtl::math::approxEqual in include/basegfx/Gabor Kelemen Turns out we can save about 500Mb of preprocessor input if we use rtl_math_approxEqual from rtl/math.h instead of its C++ wrapper rtl::math::approxEqual from rtl/math.hxx and manage the fallout accordingly. Before: bin/includebloat.awk | head sum total bytes included (excluding system headers): 19017296671 After: $ bin/includebloat.awk | head sum total bytes included (excluding system headers): 18535432672 Change-Id: I1691171f3a309405a7099882ad9989d147f59118 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/92508 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> 2020-03-10tdf#42949 Fix IWYU warnings in svx/source/[t-x]*/*cxxGabor Kelemen Found with bin/find-unneeded-includes Only removal proposals are dealt with here. Change-Id: I8d8a3e13932b004678b305f9a6883062854f9201 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90140 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> 2019-05-10tdf#62699 Drop pass-through header file include/svx/svdattr.hxxGabor Kelemen Change-Id: I04289589196ac69b31f75989d9252c79d03c890f Reviewed-on: https://gerrit.libreoffice.org/71633 Tested-by: Jenkins Reviewed-by: Miklos Vajna <vmiklos@collabora.com> 2019-02-10loplugin:indentation in svxNoel Grandin Change-Id: Ifea8e24fb76025715ab2ff495d3949223584070a Reviewed-on: https://gerrit.libreoffice.org/67567 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2018-12-08Remove obsolete SAL_FALLTHROUGH completelyStephan Bergmann ...after 7ffdd830d5fb52f2ca25aa80277d22ea6d89970b "HAVE_CPP_ATTRIBUTE_FALLTHROUGH is always true now" Change-Id: I54e5ff4e036a6bb3e5774d1c0524158aae18e937 Reviewed-on: https://gerrit.libreoffice.org/64800 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> 2018-11-28Fix SID_EXTRUSION_TOOGLE -> SID_EXTRUSION_TOGGLEAndrea Gelmini It passed "make check" on Linux. If accepted, I have to update these files: helpcontent2/helpers/help_hid.lst : SID_EXTRUSION_TOOGLE,10960,.uno:ExtrusionToggle helpcontent2/helpers/longnames_commands.csv : SID_EXTRUSION_TOOGLE,.uno:ExtrusionToggle helpcontent2/helpers/uno_hid.lst : SID_EXTRUSION_TOOGLE,10960,.uno:ExtrusionToggle Change-Id: Ie315ef92b6aa8c03c6fc180f4e82d95f28975c2e Reviewed-on: https://gerrit.libreoffice.org/60631 Tested-by: Jenkins Reviewed-by: Olivier Hallot <olivier.hallot@libreoffice.org> 2018-09-17New loplugin:externalStephan Bergmann ...warning about (for now only) functions and variables with external linkage that likely don't need it. The problems with moving entities into unnamed namespacs and breaking ADL (as alluded to in comments in compilerplugins/clang/external.cxx) are illustrated by the fact that while struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { struct S2: S1 { int f() { return 1; } }; int f(S2 s) { return s.f(); } } int main() { return f(N::S2()); } returns 1, both moving just the struct S2 into an nunnamed namespace, struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { namespace { struct S2: S1 { int f() { return 1; } }; } int f(S2 s) { return s.f(); } } int main() { return f(N::S2()); } as well as moving just the function f overload into an unnamed namespace, struct S1 { int f() { return 0; } }; int f(S1 s) { return s.f(); } namespace N { struct S2: S1 { int f() { return 1; } }; namespace { int f(S2 s) { return s.f(); } } } int main() { return f(N::S2()); } would each change the program to return 0 instead. Change-Id: I4d09f7ac5e8f9bcd6e6bde4712608444b642265c Reviewed-on: https://gerrit.libreoffice.org/60539 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com> 2018-05-14weld ExtrusionDepthDialogCaolán McNamara Change-Id: I5905fea310a7f29574d94eaf61c80b6ca09a7467 Reviewed-on: https://gerrit.libreoffice.org/54310 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com> 2018-01-15More loplugin:cstylecast: svxStephan Bergmann Change-Id: If370ad12d2885ea9a6348736a3bcab618bc2e6ec 2018-01-12More loplugin:cstylecast: svxStephan Bergmann auto-rewrite with <https://gerrit.libreoffice.org/#/c/47798/> "Enable loplugin:cstylecast for some more cases" plus solenv/clang-format/reformat-formatted-files Change-Id: I100e6c14cbf1d780f0e5ebca6b0c9e71ce1caaf7 2017-11-22TypedWhichId for SDRATTR* constants (3)Noel Grandin Change-Id: Iea72cb3a4bbf693096de46269f58259b5952eedb Reviewed-on: https://gerrit.libreoffice.org/45024 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2017-11-20TypedWhichId for XATTR* constantsNoel Grandin Change-Id: Ie9d637d701b77a549de3b00956f9c74ee8bd08c1 Reviewed-on: https://gerrit.libreoffice.org/44830 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2017-10-23loplugin:includeform: svxStephan Bergmann Change-Id: I4057fe05983fb2b63b592ffd325894c12b9cb5b2 2017-08-01loplugin:checkunusedparamsNoel Grandin the "check for taking address of function" part was generating false+ Change-Id: Iad6203850901229b7b1b2f8938c68ec703cd343f Reviewed-on: https://gerrit.libreoffice.org/40613 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2017-07-27loplugin:constparams in svxNoel Grandin and fix a bug in the plugin itself when calling operator's like the one on std::function<> Change-Id: I1617607107eeff06785c1841f69e13ad2926218e Reviewed-on: https://gerrit.libreoffice.org/40446 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2017-07-26convert SfxGroupId to scoped enumNoel Grandin in the process I had to teach the idl compiler to cope with identifiers like SfxGroupID::Math, which has the side effect of requiring a space before a ':' in some of the .sdi files. Change-Id: If256599cb8aa1dfc0a33642c5070c5560702f3ba Reviewed-on: https://gerrit.libreoffice.org/40441 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> 2017-07-21migrate to boost::gettextCaolán McNamara * all .ui files go from <interface> to <interface domain="MODULE"> e.g. vcl * all .src files go away and the english source strings folded into the .hrc as NC_("context", "source string") * ResMgr is dropped in favour of std::locale imbued by boost::locale::generator pointed at matching MODULE .mo files * UIConfig translations are folded into the module .mo, so e.g. UIConfig_cui goes from l10n target to normal one, so the res/lang.zips of UI files go away * translation via Translation::get(hrc-define-key, imbued-std::locale) * python can now be translated with its inbuilt gettext support (we keep the name strings.hrc there to keep finding the .hrc file uniform) so magic numbers can go away there * java and starbasic components can be translated via the pre-existing css.resource.StringResourceWithLocation mechanism * en-US res files go away, their strings are now the .hrc keys in the source code * remaining .res files are replaced by .mo files * in .res/.ui-lang-zip files, the old scheme missing translations of strings results in inserting the english original so something can be found, now the standard fallback of using the english original from the source key is used, so partial translations shrink dramatically in size * extract .hrc strings with hrcex which backs onto xgettext -C --add-comments --keyword=NC_:1c,2 --from-code=UTF-8 --no-wrap * extract .ui strings with uiex which backs onto xgettext --add-comments --no-wrap * qtz for gettext translations is generated at runtime as ascii-ified crc32 of content + "|" + msgid * [API CHANGE] remove deprecated binary .res resouce loader related uno apis com::sun::star::resource::OfficeResourceLoader com::sun::star::resource::XResourceBundleLoader com::sun::star::resource::XResourceBundle when translating strings via uno apis com.sun.star.resource.StringResourceWithLocation can continue to be used Change-Id: Ia2594a2672b7301d9c3421fdf31b6cfe7f3f8d0a