/src/libreoffice/svx/source/dialog/dlgutil.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 | | #include <svx/dlgutil.hxx> |
21 | | #include <svl/itemset.hxx> |
22 | | #include <sfx2/sfxsids.hrc> |
23 | | #include <sfx2/module.hxx> |
24 | | #include <svl/intitem.hxx> |
25 | | #include <svl/eitem.hxx> |
26 | | #include <sfx2/viewfrm.hxx> |
27 | | #include <sfx2/objsh.hxx> |
28 | | #include <sal/log.hxx> |
29 | | #include <vcl/virdev.hxx> |
30 | | |
31 | | FieldUnit GetModuleFieldUnit( const SfxItemSet& rSet ) |
32 | 0 | { |
33 | 0 | if (const SfxUInt16Item* pItem = rSet.GetItemIfSet(SID_ATTR_METRIC, false)) |
34 | 0 | return static_cast<FieldUnit>(pItem->GetValue()); |
35 | | |
36 | 0 | return SfxModule::GetCurrentFieldUnit(); |
37 | 0 | } |
38 | | |
39 | | bool GetApplyCharUnit( const SfxItemSet& rSet ) |
40 | 0 | { |
41 | 0 | bool bUseCharUnit = false; |
42 | 0 | if ( const SfxBoolItem* pItem = rSet.GetItemIfSet( SID_ATTR_APPLYCHARUNIT, false ) ) |
43 | 0 | bUseCharUnit = pItem->GetValue(); |
44 | 0 | else |
45 | 0 | { |
46 | | // FIXME - this might be wrong, cf. the DEV300 changes in GetModuleFieldUnit() |
47 | 0 | SfxViewFrame* pFrame = SfxViewFrame::Current(); |
48 | 0 | SfxObjectShell* pSh = nullptr; |
49 | 0 | if ( pFrame ) |
50 | 0 | pSh = pFrame->GetObjectShell(); |
51 | 0 | if ( pSh ) // the object shell is not always available during reload |
52 | 0 | { |
53 | 0 | SfxModule* pModule = pSh->GetModule(); |
54 | 0 | if ( pModule ) |
55 | 0 | { |
56 | 0 | pItem = pModule->GetItem( SID_ATTR_APPLYCHARUNIT ); |
57 | 0 | if ( pItem ) |
58 | 0 | bUseCharUnit = pItem->GetValue(); |
59 | 0 | } |
60 | 0 | else |
61 | 0 | { |
62 | 0 | SAL_WARN( "svx.dialog", "GetApplyCharUnit(): no module found" ); |
63 | 0 | } |
64 | 0 | } |
65 | 0 | } |
66 | 0 | return bUseCharUnit; |
67 | 0 | } |
68 | | |
69 | | FieldUnit GetModuleFieldUnit() |
70 | 0 | { |
71 | 0 | return SfxModule::GetCurrentFieldUnit(); |
72 | 0 | } |
73 | | |
74 | | void SvxRatioConnector::Paint(vcl::RenderContext& rRenderContext, const tools::Rectangle&) |
75 | 0 | { |
76 | | // contrast of GetDialogTextColor() is too strong |
77 | 0 | rRenderContext.SetLineColor(rRenderContext.GetSettings().GetStyleSettings().GetDisableColor()); |
78 | 0 | rRenderContext.SetBackground(rRenderContext.GetSettings().GetStyleSettings().GetDialogColor()); |
79 | |
|
80 | 0 | Size aSize(rRenderContext.PixelToLogic(GetOutputSizePixel())); |
81 | 0 | const sal_Int16 aWidth = aSize.Width() / 2; |
82 | 0 | const sal_Int16 aHeight = aSize.Height() - 1; |
83 | |
|
84 | 0 | if (m_aConType == ConnectorType::Top) |
85 | 0 | { |
86 | 0 | rRenderContext.DrawLine(Point(0, 0), Point(aWidth, 0)); //top-left |
87 | 0 | rRenderContext.DrawLine(Point(aWidth, 0), Point(aWidth, aHeight)); //bottom-right |
88 | 0 | } |
89 | 0 | else |
90 | 0 | { |
91 | 0 | rRenderContext.DrawLine(Point(0, aHeight), Point(aWidth, aHeight)); |
92 | 0 | rRenderContext.DrawLine(Point(aWidth, aHeight), Point(aWidth, 0)); |
93 | 0 | } |
94 | 0 | } |
95 | | |
96 | | /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ |