1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
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>
31 FieldUnit
GetModuleFieldUnit( const SfxItemSet
& rSet
)
33 if (const SfxUInt16Item
* pItem
= rSet
.GetItemIfSet(SID_ATTR_METRIC
, false))
34 return static_cast<FieldUnit
>(pItem
->GetValue());
36 return SfxModule::GetCurrentFieldUnit();
39 bool GetApplyCharUnit( const SfxItemSet
& rSet
)
41 bool bUseCharUnit
= false;
42 if ( const SfxBoolItem
* pItem
= rSet
.GetItemIfSet( SID_ATTR_APPLYCHARUNIT
, false ) )
43 bUseCharUnit
= pItem
->GetValue();
46 // FIXME - this might be wrong, cf. the DEV300 changes in GetModuleFieldUnit()
47 SfxViewFrame
* pFrame
= SfxViewFrame::Current();
48 SfxObjectShell
* pSh
= nullptr;
50 pSh
= pFrame
->GetObjectShell();
51 if ( pSh
) // the object shell is not always available during reload
53 SfxModule
* pModule
= pSh
->GetModule();
56 pItem
= pModule
->GetItem( SID_ATTR_APPLYCHARUNIT
);
58 bUseCharUnit
= pItem
->GetValue();
62 SAL_WARN( "svx.dialog", "GetApplyCharUnit(): no module found" );
69 FieldUnit
GetModuleFieldUnit()
71 return SfxModule::GetCurrentFieldUnit();
74 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */