2010-10-12 15:53:47 +02:00
|
|
|
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
2012-07-05 20:18:35 +01:00
|
|
|
/*
|
|
|
|
* 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 .
|
|
|
|
*/
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2010-04-20 15:55:51 +02:00
|
|
|
#include "svx/dlgutil.hxx"
|
2009-12-11 11:15:06 +01:00
|
|
|
#include <svl/itemset.hxx>
|
|
|
|
#include <sfx2/sfxsids.hrc>
|
2010-02-03 11:03:54 +01:00
|
|
|
#include <sfx2/module.hxx>
|
2010-01-07 18:52:36 +01:00
|
|
|
#include <svl/intitem.hxx>
|
2010-09-13 14:37:50 +02:00
|
|
|
#include <svl/eitem.hxx>
|
|
|
|
#include <sfx2/viewfrm.hxx>
|
|
|
|
#include <sfx2/objsh.hxx>
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2014-02-22 21:20:15 +01:00
|
|
|
|
2000-09-18 16:07:07 +00:00
|
|
|
|
2009-12-10 18:44:22 +01:00
|
|
|
FieldUnit GetModuleFieldUnit( const SfxItemSet& rSet )
|
2000-10-09 10:36:50 +00:00
|
|
|
{
|
|
|
|
FieldUnit eUnit = FUNIT_INCH;
|
2000-10-23 08:21:29 +00:00
|
|
|
const SfxPoolItem* pItem = NULL;
|
2014-02-19 21:49:02 +01:00
|
|
|
if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_METRIC, false, &pItem ) )
|
2000-10-23 08:21:29 +00:00
|
|
|
eUnit = (FieldUnit)( (const SfxUInt16Item*)pItem )->GetValue();
|
2010-02-03 11:03:54 +01:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return SfxModule::GetCurrentFieldUnit();
|
|
|
|
}
|
|
|
|
|
2000-10-09 10:36:50 +00:00
|
|
|
return eUnit;
|
|
|
|
}
|
|
|
|
|
2011-03-12 18:57:32 -06:00
|
|
|
bool GetApplyCharUnit( const SfxItemSet& rSet )
|
2010-09-13 14:37:50 +02:00
|
|
|
{
|
2011-03-12 18:57:32 -06:00
|
|
|
bool bUseCharUnit = false;
|
2010-09-13 14:37:50 +02:00
|
|
|
const SfxPoolItem* pItem = NULL;
|
2014-02-19 21:49:02 +01:00
|
|
|
if ( SFX_ITEM_SET == rSet.GetItemState( SID_ATTR_APPLYCHARUNIT, false, &pItem ) )
|
2011-03-12 18:57:32 -06:00
|
|
|
bUseCharUnit = ((const SfxBoolItem*)pItem )->GetValue();
|
2010-09-13 14:37:50 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
// FIXME - this might be wrong, cf. the DEV300 changes in GetModuleFieldUnit()
|
|
|
|
SfxViewFrame* pFrame = SfxViewFrame::Current();
|
|
|
|
SfxObjectShell* pSh = NULL;
|
|
|
|
if ( pFrame )
|
|
|
|
pSh = pFrame->GetObjectShell();
|
2011-02-21 23:29:31 +01:00
|
|
|
if ( pSh ) // the object shell is not always available during reload
|
2010-09-13 14:37:50 +02:00
|
|
|
{
|
|
|
|
SfxModule* pModule = pSh->GetModule();
|
|
|
|
if ( pModule )
|
|
|
|
{
|
|
|
|
pItem = pModule->GetItem( SID_ATTR_APPLYCHARUNIT );
|
|
|
|
if ( pItem )
|
2011-03-12 18:57:32 -06:00
|
|
|
bUseCharUnit = ((SfxBoolItem*)pItem )->GetValue();
|
2010-09-13 14:37:50 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2012-01-16 19:34:11 +01:00
|
|
|
SAL_WARN( "svx.dialog", "GetApplyCharUnit(): no module found" );
|
2010-09-13 14:37:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return bUseCharUnit;
|
|
|
|
}
|
2010-10-12 15:53:47 +02:00
|
|
|
|
2013-04-10 08:20:16 +00:00
|
|
|
FieldUnit GetModuleFieldUnit()
|
|
|
|
{
|
|
|
|
return SfxModule::GetCurrentFieldUnit();
|
|
|
|
}
|
|
|
|
|
2010-10-12 15:53:47 +02:00
|
|
|
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|